espressif_tinyusb/hw/bsp/board.h

125 lines
3.6 KiB
C
Raw Normal View History

/*
* 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.
*/
2018-03-02 07:41:35 +01:00
/** \ingroup group_demo
* \defgroup group_board Boards Abstraction Layer
* @{ */
2018-11-13 06:32:15 +01:00
#ifndef _BSP_BOARD_H_
#define _BSP_BOARD_H_
2018-03-02 07:41:35 +01:00
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdbool.h>
#include "ansi_escape.h"
2018-12-04 07:17:12 +01:00
// NXP LPC
2018-11-13 06:32:15 +01:00
#if defined BOARD_LPCXPRESSO11U14
2018-03-02 12:38:29 +01:00
#include "lpcxpresso11u14/board_lpcxpresso11u14.h"
2018-11-13 06:32:15 +01:00
#elif defined BOARD_LPCXPRESSO1347
2018-03-02 12:38:29 +01:00
#include "lpcxpresso1347/board_lpcxpresso1347.h"
2018-12-04 07:17:12 +01:00
#elif defined BOARD_LPCXPRESSO11U68
#include "lpcxpresso11u68/board_lpcxpresso11u68.h"
2018-11-13 06:32:15 +01:00
#elif defined BOARD_LPCXPRESSO1769
2018-03-02 12:38:29 +01:00
#include "lpcxpresso1769/board_lpcxpresso1769.h"
2018-12-04 07:17:12 +01:00
#elif defined BOARD_MCB1800
#include "mcb1800/board_mcb1800.h"
#elif defined BOARD_EA4088QS
#include "ea4088qs/board_ea4088qs.h"
2018-11-13 06:32:15 +01:00
#elif defined BOARD_EA4357
2018-03-02 08:53:40 +01:00
#include "ea4357/board_ea4357.h"
2018-12-04 07:17:12 +01:00
// Nordic nRF
#elif defined BOARD_PCA10056
2018-11-13 11:26:17 +01:00
#include "pca10056/board_pca10056.h"
2018-12-04 07:17:12 +01:00
// Atmel SAM
2018-11-13 11:26:17 +01:00
#elif defined BOARD_METRO_M4_EXPRESS
#include "metro_m4_express/board_metro_m4_express.h"
#elif defined BOARD_METRO_M0_EXPRESS
2018-11-20 17:19:59 +01:00
#include "metro_m0_express/board_metro_m0_express.h"
2018-11-28 03:11:03 +01:00
#elif defined BOARD_STM32F407G_DISC1
#include "stm32f407g_disc1/board_stm32f407g_disc1.h"
2018-03-02 07:41:35 +01:00
#else
#error BOARD is not defined or supported yet
#endif
2018-11-13 06:32:15 +01:00
#define CFG_UART_BAUDRATE 115200
#define BOARD_TICKS_HZ 1000
2018-11-13 06:32:15 +01:00
#define board_tick2ms(tck) ( ( ((uint64_t)(tck)) * 1000) / BOARD_TICKS_HZ )
2018-03-02 07:41:35 +01:00
2018-11-13 06:32:15 +01:00
/// Initialize on-board peripherals
2018-03-02 07:41:35 +01:00
void board_init(void);
2018-11-13 06:32:15 +01:00
//--------------------------------------------------------------------+
// LED
2018-12-03 12:48:43 +01:00
// Board layer use only 1 LED for indicator
2018-11-13 06:32:15 +01:00
//--------------------------------------------------------------------+
2018-12-03 12:48:43 +01:00
void board_led_control(bool state);
2018-03-13 10:30:53 +01:00
2018-12-03 12:48:43 +01:00
static inline void board_led_on(void)
2018-03-13 10:30:53 +01:00
{
2018-12-03 12:48:43 +01:00
board_led_control(true);
2018-03-13 10:30:53 +01:00
}
2018-12-03 12:48:43 +01:00
static inline void board_led_off(void)
2018-03-13 10:30:53 +01:00
{
2018-12-03 12:48:43 +01:00
board_led_control(false);
2018-03-13 10:30:53 +01:00
}
2018-11-13 06:32:15 +01:00
//--------------------------------------------------------------------+
// Buttons
// TODO refractor later
//--------------------------------------------------------------------+
/** Get the current state of the buttons on the board
2018-03-02 07:41:35 +01:00
* \return Bitmask where a '1' means active (pressed), a '0' means inactive.
*/
uint32_t board_buttons(void);
2018-11-13 06:32:15 +01:00
/** Get a character input from UART
2018-03-02 07:41:35 +01:00
* \return ASCII code of the input character or zero if none.
*/
uint8_t board_uart_getchar(void);
2018-11-13 06:32:15 +01:00
/** Send a character to UART
2018-03-02 07:41:35 +01:00
* \param[in] c the character to be sent
*/
void board_uart_putchar(uint8_t c);
#ifdef __cplusplus
}
#endif
2018-11-13 06:32:15 +01:00
#endif /* _BSP_BOARD_H_ */
2018-03-02 07:41:35 +01:00
/** @} */