generated from Embedded_Projects/MPyATE_Template
Fixed BLUE LED, added UART skeleton.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Signed-off-by: Yilin Sun <imi415@imi.moe>
This commit is contained in:
parent
5e1cb6080f
commit
ecd9ef8220
|
@ -49,6 +49,7 @@ set(TARGET_SOURCES
|
|||
"src/app_gpio.c"
|
||||
"src/app_reg_if.c"
|
||||
"src/app_sys_utils.c"
|
||||
"src/app_uart.c"
|
||||
"src/main.c"
|
||||
)
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef APP_UART_H
|
||||
#define APP_UART_H
|
||||
|
||||
#include "fsl_common_arm.h"
|
||||
|
||||
void app_uart_init(void);
|
||||
uint16_t app_uart_module_reg_read(uint8_t addr);
|
||||
void app_uart_module_reg_write(uint8_t addr, uint16_t data);
|
||||
|
||||
#endif // APP_UART_H
|
|
@ -3,6 +3,7 @@
|
|||
#include "app_dac.h"
|
||||
#include "app_gpio.h"
|
||||
#include "app_sys_utils.h"
|
||||
#include "app_uart.h"
|
||||
|
||||
/* Private */
|
||||
#include "app_reg_if.h"
|
||||
|
@ -11,7 +12,8 @@
|
|||
#define MODULE_ID_GPIO 1
|
||||
#define MODULE_ID_ADC 2
|
||||
#define MODULE_ID_DAC 3
|
||||
#define MODULE_ID_END 4
|
||||
#define MODULE_ID_UART 4
|
||||
#define MODULE_ID_END 5
|
||||
|
||||
typedef uint16_t (*module_reg_read_t)(uint8_t offset);
|
||||
typedef void (*module_reg_write_t)(uint8_t offset, uint16_t data);
|
||||
|
@ -42,6 +44,11 @@ static const module_reg_t s_module_regs[MODULE_ID_END] = {
|
|||
.read = app_dac_module_reg_read,
|
||||
.write = app_dac_module_reg_write,
|
||||
},
|
||||
[MODULE_ID_UART] =
|
||||
{
|
||||
.read = app_uart_module_reg_read,
|
||||
.write = app_uart_module_reg_write,
|
||||
},
|
||||
};
|
||||
|
||||
uint16_t app_reg_if_read(uint8_t reg) {
|
||||
|
|
|
@ -13,13 +13,27 @@
|
|||
#define APP_SYS_CONST_ID (0xEACEU)
|
||||
#define APP_SYS_CONST_VER (0x0000U)
|
||||
|
||||
#define APP_SYS_CFG_GPIO0_FUNC_Pos (0U)
|
||||
#define APP_SYS_CFG_GPIO0_FUNC_Msk (3U << APP_SYS_CFG_GPIO0_FUNC_Pos)
|
||||
|
||||
#define APP_SYS_CFG_GPIO1_FUNC_Pos (2U)
|
||||
#define APP_SYS_CFG_GPIO1_FUNC_Msk (3U << APP_SYS_CFG_GPIO1_FUNC_Pos)
|
||||
|
||||
#define APP_SYS_CFG_GPIO2_FUNC_Pos (4U)
|
||||
#define APP_SYS_CFG_GPIO2_FUNC_Msk (3U << APP_SYS_CFG_GPIO2_FUNC_Pos)
|
||||
|
||||
#define APP_SYS_CFG_GPIO3_FUNC_Pos (6U)
|
||||
#define APP_SYS_CFG_GPIO3_FUNC_Msk (3U << APP_SYS_CFG_GPIO3_FUNC_Pos)
|
||||
|
||||
#define APP_SYS_CFG_RST_Pos (15U)
|
||||
#define APP_SYS_CFG_RST_Msk (1U << APP_SYS_CFG_RST_Pos)
|
||||
|
||||
#define APP_SYS_AUX_LED_R_Pos (0U)
|
||||
#define APP_SYS_AUX_LED_R_Msk (1U << APP_SYS_AUX_LED_R_Pos)
|
||||
|
||||
#define APP_SYS_AUX_LED_G_Pos (1U)
|
||||
#define APP_SYS_AUX_LED_G_Msk (1U << APP_SYS_AUX_LED_G_Pos)
|
||||
|
||||
#define APP_SYS_AUX_LED_B_Pos (2U)
|
||||
#define APP_SYS_AUX_LED_B_Msk (1U << APP_SYS_AUX_LED_B_Pos)
|
||||
|
||||
|
@ -122,7 +136,7 @@ static inline void app_sys_utils_write_reg_aux(uint16_t data) {
|
|||
app_led_off(APP_LED_GREEN);
|
||||
}
|
||||
|
||||
if (data & APP_LED_BLUE) {
|
||||
if (data & APP_SYS_AUX_LED_B_Msk) {
|
||||
app_led_on(APP_LED_BLUE);
|
||||
} else {
|
||||
app_led_off(APP_LED_BLUE);
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#include "app_uart.h"
|
||||
|
||||
void app_uart_init(void) {
|
||||
}
|
||||
|
||||
uint16_t app_uart_module_reg_read(uint8_t addr) {
|
||||
return 0x0000;
|
||||
}
|
||||
|
||||
void app_uart_module_reg_write(uint8_t addr, uint16_t data) {
|
||||
}
|
|
@ -9,6 +9,7 @@
|
|||
#include "app_gpio.h"
|
||||
#include "app_i2c_if.h"
|
||||
#include "app_sys_utils.h"
|
||||
#include "app_uart.h"
|
||||
|
||||
int main(void) {
|
||||
BOARD_InitBootPins();
|
||||
|
@ -18,6 +19,7 @@ int main(void) {
|
|||
app_gpio_init();
|
||||
app_adc_init();
|
||||
app_dac_init();
|
||||
app_uart_init();
|
||||
app_i2c_if_init();
|
||||
|
||||
for (;;) {
|
||||
|
|
Loading…
Reference in New Issue