diff --git a/CMakeLists.txt b/CMakeLists.txt index 87ed163..60c5a22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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" ) diff --git a/include/app_uart.h b/include/app_uart.h new file mode 100644 index 0000000..d3cc79e --- /dev/null +++ b/include/app_uart.h @@ -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 diff --git a/src/app_reg_if.c b/src/app_reg_if.c index a2b3655..e0b1ad1 100644 --- a/src/app_reg_if.c +++ b/src/app_reg_if.c @@ -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) { diff --git a/src/app_sys_utils.c b/src/app_sys_utils.c index 6328ea0..65ae1f3 100644 --- a/src/app_sys_utils.c +++ b/src/app_sys_utils.c @@ -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); diff --git a/src/app_uart.c b/src/app_uart.c new file mode 100644 index 0000000..7c6671d --- /dev/null +++ b/src/app_uart.c @@ -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) { +} \ No newline at end of file diff --git a/src/main.c b/src/main.c index 500c7a0..f25568b 100644 --- a/src/main.c +++ b/src/main.c @@ -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 (;;) {