/* * The MIT License (MIT) * * Copyright (c) 2018, hathach (tinyusb.org) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * This file is part of the TinyUSB stack. */ /** \ingroup group_demo * \defgroup group_board Boards Abstraction Layer * @{ */ #ifndef _BSP_BOARD_H_ #define _BSP_BOARD_H_ #ifdef __cplusplus extern "C" { #endif #include #include #include "ansi_escape.h" #define CFG_UART_BAUDRATE 115200 #define BOARD_TICKS_HZ 1000 #define board_tick2ms(tck) ( ( ((uint64_t)(tck)) * 1000) / BOARD_TICKS_HZ ) //--------------------------------------------------------------------+ // Board Porting API //--------------------------------------------------------------------+ // Initialize on-board peripherals : led, button, uart and USB void board_init(void); // Turn LED on or off void board_led_control(bool state); // Get the current state of buttons on the board // \return Bitmask where a '1' means active (pressed), a '0' means inactive. uint32_t board_buttons(void); // Get characters from UART int board_uart_read(uint8_t* buf, int len); // Send characters to UART int board_uart_write(void const * buf, int len); // Get current milliseconds with no rtos configure (TUSB_CFG_OS = OPT_OS_NONE) uint32_t board_noos_millis(void); //--------------------------------------------------------------------+ // Helper functions //--------------------------------------------------------------------+ static inline void board_led_on(void) { board_led_control(true); } static inline void board_led_off(void) { board_led_control(false); } static inline int8_t board_uart_getchar(void) { uint8_t c; return board_uart_read(&c, 1) ? c : (-1); } static inline int board_uart_putchar(uint8_t c) { return board_uart_write(&c, 1); } #ifdef __cplusplus } #endif #endif /* _BSP_BOARD_H_ */ /** @} */