diff options
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/boards/frdmkv31f/project_template/board.h')
-rw-r--r-- | lib/chibios-contrib/ext/mcux-sdk/boards/frdmkv31f/project_template/board.h | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/boards/frdmkv31f/project_template/board.h b/lib/chibios-contrib/ext/mcux-sdk/boards/frdmkv31f/project_template/board.h new file mode 100644 index 000000000..bb4e334f3 --- /dev/null +++ b/lib/chibios-contrib/ext/mcux-sdk/boards/frdmkv31f/project_template/board.h | |||
@@ -0,0 +1,156 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2016, Freescale Semiconductor, Inc. | ||
3 | * Copyright 2016-2018 NXP | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * SPDX-License-Identifier: BSD-3-Clause | ||
7 | */ | ||
8 | |||
9 | #ifndef _BOARD_H_ | ||
10 | #define _BOARD_H_ | ||
11 | |||
12 | #include "clock_config.h" | ||
13 | #include "fsl_gpio.h" | ||
14 | |||
15 | /******************************************************************************* | ||
16 | * Definitions | ||
17 | ******************************************************************************/ | ||
18 | /*! @brief The board name */ | ||
19 | #define BOARD_NAME "FRDM-KV31F" | ||
20 | |||
21 | /*! @brief The UART to use for debug messages. */ | ||
22 | #define BOARD_USE_UART | ||
23 | #define BOARD_DEBUG_UART_TYPE kSerialPort_Uart | ||
24 | #define BOARD_DEBUG_UART_BASEADDR (uint32_t) UART0 | ||
25 | #define BOARD_DEBUG_UART_INSTANCE 0U | ||
26 | #define BOARD_DEBUG_UART_CLKSRC kCLOCK_CoreSysClk | ||
27 | #define BOARD_DEBUG_UART_CLK_FREQ CLOCK_GetCoreSysClkFreq() | ||
28 | #define BOARD_UART_IRQ UART0_RX_TX_IRQn | ||
29 | #define BOARD_UART_IRQ_HANDLER UART0_RX_TX_IRQHandler | ||
30 | |||
31 | #ifndef BOARD_DEBUG_UART_BAUDRATE | ||
32 | #define BOARD_DEBUG_UART_BAUDRATE 115200 | ||
33 | #endif /* BOARD_DEBUG_UART_BAUDRATE */ | ||
34 | |||
35 | /*! @brief The Flextimer instance/channel used for board */ | ||
36 | #define BOARD_FTM_BASEADDR FTM0 | ||
37 | |||
38 | /*! @brief The i2c instance used for board. */ | ||
39 | #define BOARD_I2C_COMM_BASEADDR I2C0 | ||
40 | /*! @brief The i2c instance used for i2c connection by default */ | ||
41 | #define BOARD_I2C_BASEADDR I2C0 | ||
42 | |||
43 | /*! @brief The bubble level demo information */ | ||
44 | #define BOARD_FXOS8700_ADDR 0x1D | ||
45 | #define BOARD_ACCEL_ADDR BOARD_FXOS8700_ADDR | ||
46 | #define BOARD_ACCEL_BAUDRATE 100 | ||
47 | #define BOARD_ACCEL_I2C_BASEADDR I2C0 | ||
48 | #define BOARD_ACCEL_I2C_CLOCK_FREQ CLOCK_GetFreq(I2C0_CLK_SRC) | ||
49 | |||
50 | /*! @brief The CMP instance/channel used for board. */ | ||
51 | #define BOARD_CMP_BASEADDR CMP0 | ||
52 | #define BOARD_CMP_CHANNEL 0U | ||
53 | |||
54 | /*! @brief Define the port interrupt number for the board switches */ | ||
55 | #ifndef BOARD_SW2_GPIO | ||
56 | #define BOARD_SW2_GPIO GPIOA | ||
57 | #endif | ||
58 | #ifndef BOARD_SW2_PORT | ||
59 | #define BOARD_SW2_PORT PORTA | ||
60 | #endif | ||
61 | #ifndef BOARD_SW2_GPIO_PIN | ||
62 | #define BOARD_SW2_GPIO_PIN 4U | ||
63 | #endif | ||
64 | #define BOARD_SW2_IRQ PORTA_IRQn | ||
65 | #define BOARD_SW2_IRQ_HANDLER PORTA_IRQHandler | ||
66 | #define BOARD_SW2_NAME "SW2" | ||
67 | |||
68 | /* Board led color mapping */ | ||
69 | #define LOGIC_LED_ON 0U | ||
70 | #define LOGIC_LED_OFF 1U | ||
71 | #ifndef BOARD_LED_RED_GPIO | ||
72 | #define BOARD_LED_RED_GPIO GPIOD | ||
73 | #endif | ||
74 | #define BOARD_LED_RED_GPIO_PORT PORTD | ||
75 | #ifndef BOARD_LED_RED_GPIO_PIN | ||
76 | #define BOARD_LED_RED_GPIO_PIN 1U | ||
77 | #endif | ||
78 | #ifndef BOARD_LED_GREEN_GPIO | ||
79 | #define BOARD_LED_GREEN_GPIO GPIOD | ||
80 | #endif | ||
81 | #define BOARD_LED_GREEN_GPIO_PORT PORTD | ||
82 | #ifndef BOARD_LED_GREEN_GPIO_PIN | ||
83 | #define BOARD_LED_GREEN_GPIO_PIN 7U | ||
84 | #endif | ||
85 | #ifndef BOARD_LED_BLUE_GPIO | ||
86 | #define BOARD_LED_BLUE_GPIO GPIOE | ||
87 | #endif | ||
88 | #define BOARD_LED_BLUE_GPIO_PORT PORTE | ||
89 | #ifndef BOARD_LED_BLUE_GPIO_PIN | ||
90 | #define BOARD_LED_BLUE_GPIO_PIN 25U | ||
91 | #endif | ||
92 | |||
93 | #define LED_RED_INIT(output) \ | ||
94 | GPIO_PinWrite(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PIN, output); \ | ||
95 | BOARD_LED_RED_GPIO->PDDR |= (1U << BOARD_LED_RED_GPIO_PIN) /*!< Enable target LED_RED */ | ||
96 | #define LED_RED_ON() GPIO_PortClear(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn on target LED_RED */ | ||
97 | #define LED_RED_OFF() GPIO_PortSet(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn off target LED_RED */ | ||
98 | #define LED_RED_TOGGLE() \ | ||
99 | GPIO_PortToggle(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Toggle on target LED_RED */ | ||
100 | |||
101 | #define LED_GREEN_INIT(output) \ | ||
102 | GPIO_PinWrite(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PIN, output); \ | ||
103 | BOARD_LED_GREEN_GPIO->PDDR |= (1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Enable target LED_GREEN */ | ||
104 | #define LED_GREEN_ON() \ | ||
105 | GPIO_PortClear(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn on target LED_GREEN */ | ||
106 | #define LED_GREEN_OFF() \ | ||
107 | GPIO_PortSet(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn off target LED_GREEN */ | ||
108 | #define LED_GREEN_TOGGLE() \ | ||
109 | GPIO_PortToggle(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Toggle on target LED_GREEN */ | ||
110 | |||
111 | #define LED_BLUE_INIT(output) \ | ||
112 | GPIO_PinWrite(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PIN, output); \ | ||
113 | BOARD_LED_BLUE_GPIO->PDDR |= (1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Enable target LED_BLUE */ | ||
114 | #define LED_BLUE_ON() \ | ||
115 | GPIO_PortClear(BOARD_LED_BLUE_GPIO, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn on target LED_BLUE \ | ||
116 | */ | ||
117 | #define LED_BLUE_OFF() \ | ||
118 | GPIO_PortSet(BOARD_LED_BLUE_GPIO, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn off target LED_BLUE \ | ||
119 | */ | ||
120 | #define LED_BLUE_TOGGLE() \ | ||
121 | GPIO_PortToggle(BOARD_LED_BLUE_GPIO, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Toggle on target LED_BLUE */ | ||
122 | |||
123 | #if defined(__cplusplus) | ||
124 | extern "C" { | ||
125 | #endif /* __cplusplus */ | ||
126 | |||
127 | /******************************************************************************* | ||
128 | * API | ||
129 | ******************************************************************************/ | ||
130 | |||
131 | void BOARD_InitDebugConsole(void); | ||
132 | #if defined(SDK_I2C_BASED_COMPONENT_USED) && SDK_I2C_BASED_COMPONENT_USED | ||
133 | void BOARD_I2C_Init(I2C_Type *base, uint32_t clkSrc_Hz); | ||
134 | status_t BOARD_I2C_Send(I2C_Type *base, | ||
135 | uint8_t deviceAddress, | ||
136 | uint32_t subAddress, | ||
137 | uint8_t subaddressSize, | ||
138 | uint8_t *txBuff, | ||
139 | uint8_t txBuffSize); | ||
140 | status_t BOARD_I2C_Receive(I2C_Type *base, | ||
141 | uint8_t deviceAddress, | ||
142 | uint32_t subAddress, | ||
143 | uint8_t subaddressSize, | ||
144 | uint8_t *rxBuff, | ||
145 | uint8_t rxBuffSize); | ||
146 | void BOARD_Accel_I2C_Init(void); | ||
147 | status_t BOARD_Accel_I2C_Send(uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint32_t txBuff); | ||
148 | status_t BOARD_Accel_I2C_Receive( | ||
149 | uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); | ||
150 | #endif /* SDK_I2C_BASED_COMPONENT_USED */ | ||
151 | |||
152 | #if defined(__cplusplus) | ||
153 | } | ||
154 | #endif /* __cplusplus */ | ||
155 | |||
156 | #endif /* _BOARD_H_ */ | ||