├── driver ├── bl24c512 │ ├── bl24c512.c │ └── bl24c512.h ├── key │ ├── key.c │ ├── key.h │ └── key_desc.h ├── esp_at │ ├── esp_at.c │ └── esp_at.h ├── st7789 │ ├── st7789.c │ └── st7789.h ├── aht20 │ ├── aht20.h │ └── aht20.c ├── led │ ├── led_desc.h │ ├── led.h │ └── led.c ├── console │ ├── console.h │ └── console.c ├── tim_delay │ ├── tim_delay.h │ └── tim_delay.c └── rtc │ ├── rtc.h │ └── rtc.c ├── README.md ├── app ├── page │ ├── main_page.c │ ├── wifi_page.c │ ├── welcome_page.c │ ├── error_page.c │ └── page.h ├── font │ ├── font20_maple_bold.c │ ├── font24_maple_bold.c │ ├── font32_maple_bold.c │ ├── font24_maple_semibold.c │ ├── font.h │ └── font16_maple.c ├── app.h ├── workqueue.h ├── wifi.h ├── weather.h ├── ui.h ├── image │ ├── image.h │ └── icon_wifi.c ├── main.c ├── workqueue.c ├── wifi.c ├── weather.c ├── board.c ├── ui.c └── app.c ├── docs └── image │ └── vxcode.jpg ├── .gitignore ├── resources ├── design │ ├── 主页.png │ ├── 欢迎页.png │ ├── 错误页.png │ └── WiFI连接页.png └── images │ ├── icon_na.jpg │ ├── icon_na.png │ ├── img_wifi.jpg │ ├── img_wifi.png │ ├── icon_duoyun.jpg │ ├── icon_duoyun.png │ ├── icon_qing.jpg │ ├── icon_qing.png │ ├── icon_wifi.jpg │ ├── icon_wifi.png │ ├── img_error.jpg │ ├── img_error.png │ ├── img_meihua.jpg │ ├── img_meihua.png │ ├── icon_wenduji.jpg │ ├── icon_wenduji.png │ ├── icon_yintian.jpg │ ├── icon_yintian.png │ ├── icon_yueliang.jpg │ ├── icon_yueliang.png │ ├── icon_zhongxue.jpg │ ├── icon_zhongxue.png │ ├── icon_zhongyu.jpg │ ├── icon_zhongyu.png │ ├── icon_leizhenyu.jpg │ └── icon_leizhenyu.png ├── firmware ├── cmsis │ ├── device │ │ ├── stm32f4xx.h │ │ ├── system_stm32f4xx.c │ │ ├── stm32f4xx_it.h │ │ ├── system_stm32f4xx.h │ │ ├── stm32f4xx_it.c │ │ └── stm32f4xx_conf.h │ └── core │ │ ├── arm_const_structs.h │ │ └── arm_common_tables.h └── driver │ ├── src │ ├── stm32f4xx_qspi.c │ ├── stm32f4xx_crc.c │ ├── stm32f4xx_flash_ramfunc.c │ ├── stm32f4xx_dbgmcu.c │ └── stm32f4xx_iwdg.c │ └── inc │ ├── stm32f4xx_crc.h │ ├── stm32f4xx_flash_ramfunc.h │ ├── stm32f4xx_wwdg.h │ ├── stm32f4xx_dbgmcu.h │ ├── stm32f4xx_rng.h │ ├── stm32f4xx_iwdg.h │ ├── misc.h │ ├── stm32f4xx_exti.h │ └── stm32f4xx_pwr.h ├── .vscode ├── settings.json └── c_cpp_properties.json ├── .editorconfig ├── tools └── convert_chinese_font.py └── third_lib └── freertos ├── portable └── FreeRTOSConfig.h └── include ├── projdefs.h ├── stack_macros.h ├── deprecated_definitions.h └── portable.h /driver/bl24c512/bl24c512.c: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/README.md -------------------------------------------------------------------------------- /driver/key/key.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/driver/key/key.c -------------------------------------------------------------------------------- /app/page/main_page.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/app/page/main_page.c -------------------------------------------------------------------------------- /app/page/wifi_page.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/app/page/wifi_page.c -------------------------------------------------------------------------------- /docs/image/vxcode.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/docs/image/vxcode.jpg -------------------------------------------------------------------------------- /driver/esp_at/esp_at.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/driver/esp_at/esp_at.c -------------------------------------------------------------------------------- /driver/st7789/st7789.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/driver/st7789/st7789.c -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # mdk project 2 | /mdk/* 3 | !/mdk/*.uvprojx 4 | 5 | # ugreen nas sync 6 | **/@eaDir 7 | -------------------------------------------------------------------------------- /app/page/welcome_page.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/app/page/welcome_page.c -------------------------------------------------------------------------------- /resources/design/主页.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/design/主页.png -------------------------------------------------------------------------------- /resources/design/欢迎页.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/design/欢迎页.png -------------------------------------------------------------------------------- /resources/design/错误页.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/design/错误页.png -------------------------------------------------------------------------------- /app/font/font20_maple_bold.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/app/font/font20_maple_bold.c -------------------------------------------------------------------------------- /app/font/font24_maple_bold.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/app/font/font24_maple_bold.c -------------------------------------------------------------------------------- /app/font/font32_maple_bold.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/app/font/font32_maple_bold.c -------------------------------------------------------------------------------- /resources/design/WiFI连接页.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/design/WiFI连接页.png -------------------------------------------------------------------------------- /resources/images/icon_na.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/icon_na.jpg -------------------------------------------------------------------------------- /resources/images/icon_na.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/icon_na.png -------------------------------------------------------------------------------- /resources/images/img_wifi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/img_wifi.jpg -------------------------------------------------------------------------------- /resources/images/img_wifi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/img_wifi.png -------------------------------------------------------------------------------- /app/font/font24_maple_semibold.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/app/font/font24_maple_semibold.c -------------------------------------------------------------------------------- /resources/images/icon_duoyun.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/icon_duoyun.jpg -------------------------------------------------------------------------------- /resources/images/icon_duoyun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/icon_duoyun.png -------------------------------------------------------------------------------- /resources/images/icon_qing.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/icon_qing.jpg -------------------------------------------------------------------------------- /resources/images/icon_qing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/icon_qing.png -------------------------------------------------------------------------------- /resources/images/icon_wifi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/icon_wifi.jpg -------------------------------------------------------------------------------- /resources/images/icon_wifi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/icon_wifi.png -------------------------------------------------------------------------------- /resources/images/img_error.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/img_error.jpg -------------------------------------------------------------------------------- /resources/images/img_error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/img_error.png -------------------------------------------------------------------------------- /resources/images/img_meihua.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/img_meihua.jpg -------------------------------------------------------------------------------- /resources/images/img_meihua.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/img_meihua.png -------------------------------------------------------------------------------- /driver/bl24c512/bl24c512.h: -------------------------------------------------------------------------------- 1 | #ifndef __BL24C512_H 2 | #define __BL24C512_H 3 | 4 | 5 | 6 | #endif /* __BL24C512_H */ 7 | -------------------------------------------------------------------------------- /firmware/cmsis/device/stm32f4xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/firmware/cmsis/device/stm32f4xx.h -------------------------------------------------------------------------------- /resources/images/icon_wenduji.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/icon_wenduji.jpg -------------------------------------------------------------------------------- /resources/images/icon_wenduji.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/icon_wenduji.png -------------------------------------------------------------------------------- /resources/images/icon_yintian.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/icon_yintian.jpg -------------------------------------------------------------------------------- /resources/images/icon_yintian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/icon_yintian.png -------------------------------------------------------------------------------- /resources/images/icon_yueliang.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/icon_yueliang.jpg -------------------------------------------------------------------------------- /resources/images/icon_yueliang.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/icon_yueliang.png -------------------------------------------------------------------------------- /resources/images/icon_zhongxue.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/icon_zhongxue.jpg -------------------------------------------------------------------------------- /resources/images/icon_zhongxue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/icon_zhongxue.png -------------------------------------------------------------------------------- /resources/images/icon_zhongyu.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/icon_zhongyu.jpg -------------------------------------------------------------------------------- /resources/images/icon_zhongyu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/icon_zhongyu.png -------------------------------------------------------------------------------- /firmware/driver/src/stm32f4xx_qspi.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/firmware/driver/src/stm32f4xx_qspi.c -------------------------------------------------------------------------------- /resources/images/icon_leizhenyu.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/icon_leizhenyu.jpg -------------------------------------------------------------------------------- /resources/images/icon_leizhenyu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/resources/images/icon_leizhenyu.png -------------------------------------------------------------------------------- /firmware/cmsis/device/system_stm32f4xx.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuxingcao6/WeatherClock/HEAD/firmware/cmsis/device/system_stm32f4xx.c -------------------------------------------------------------------------------- /app/app.h: -------------------------------------------------------------------------------- 1 | #ifndef __APP_H__ 2 | #define __APP_H__ 3 | 4 | #define APP_VERSION "v1.0" 5 | 6 | void app_init(void); 7 | 8 | #endif /* __APP_H__ */ 9 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "*.h": "c" 4 | }, 5 | "files.autoGuessEncoding": false, 6 | "files.encoding": "gb2312" 7 | } 8 | -------------------------------------------------------------------------------- /app/workqueue.h: -------------------------------------------------------------------------------- 1 | #ifndef __APP_WORKQUEUE_H__ 2 | #define __APP_WORKQUEUE_H__ 3 | 4 | typedef void (*work_t)(void *param); 5 | 6 | void workqueue_init(void); 7 | void workqueue_run(work_t work, void *param); 8 | 9 | #endif /* __APP_WORKQUEUE_H__ */ 10 | -------------------------------------------------------------------------------- /app/wifi.h: -------------------------------------------------------------------------------- 1 | #ifndef __WIFI_H__ 2 | #define __WIFI_H__ 3 | 4 | #define APP_VERSION "v1.0" 5 | #define WIFI_SSID "vivo X200 Pro mini" 6 | #define WIFI_PASSWD "abc123456" 7 | 8 | void wifi_init(void); 9 | void wifi_wait_connect(void); 10 | 11 | 12 | #endif /* __WIFI_H__ */ 13 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | [*] 7 | indent_style = space 8 | indent_size = 4 9 | end_of_line = crlf 10 | charset = utf-8 11 | trim_trailing_whitespace = true 12 | insert_final_newline = true 13 | -------------------------------------------------------------------------------- /driver/aht20/aht20.h: -------------------------------------------------------------------------------- 1 | #ifndef __AHT20_H__ 2 | #define __AHT20_H__ 3 | 4 | #include 5 | #include 6 | 7 | bool aht20_init(void); 8 | bool aht20_start_measurement(void); 9 | bool aht20_wait_for_measurement(void); 10 | bool aht20_read_measurement(float *temperature, float *humidity); 11 | 12 | #endif /* __AHT20_H__ */ 13 | -------------------------------------------------------------------------------- /driver/led/led_desc.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_DESC_H__ 2 | #define __LED_DESC_H__ 3 | 4 | #include 5 | #include 6 | #include "stm32f4xx.h" 7 | 8 | struct led_desc 9 | { 10 | GPIO_TypeDef* Port; 11 | uint32_t Pin; 12 | BitAction OnBit; 13 | BitAction OffBit; 14 | }; 15 | 16 | #endif /* __LED_DESC_H__ */ 17 | -------------------------------------------------------------------------------- /driver/console/console.h: -------------------------------------------------------------------------------- 1 | #ifndef __CONSOLE_H__ 2 | #define __CONSOLE_H__ 3 | 4 | #include 5 | 6 | typedef void (*console_received_func_t)(uint8_t data); 7 | 8 | void console_init(void); 9 | void console_write(const char str[]); 10 | void console_received_register(console_received_func_t func); 11 | 12 | #endif /* __CONSOLE_H__ */ 13 | -------------------------------------------------------------------------------- /driver/led/led.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H__ 2 | #define __LED_H__ 3 | 4 | #include 5 | #include 6 | 7 | struct led_desc; 8 | typedef struct led_desc *led_desc_t; 9 | 10 | void led_init(led_desc_t led); 11 | void led_set(led_desc_t led, bool onoff); 12 | void led_on(led_desc_t led); 13 | void led_off(led_desc_t led); 14 | 15 | 16 | #endif /* __LED_H__ */ 17 | -------------------------------------------------------------------------------- /app/weather.h: -------------------------------------------------------------------------------- 1 | #ifndef __WEAHTER_H__ 2 | #define __WEAHTER_H__ 3 | 4 | #include 5 | #include 6 | 7 | typedef struct 8 | { 9 | char city[32]; 10 | char loaction[128]; 11 | char weather[16]; 12 | int weather_code; 13 | float temperature; 14 | } weather_info_t; 15 | 16 | bool parse_seniverse_response(const char *response, weather_info_t *info); 17 | 18 | #endif /* __WEAHTER_H__ */ 19 | -------------------------------------------------------------------------------- /driver/key/key.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_H__ 2 | #define __KEY_H__ 3 | 4 | #include 5 | #include 6 | 7 | struct key_desc; 8 | typedef struct key_desc *key_desc_t; 9 | 10 | typedef void (*key_func_t)(key_desc_t key); 11 | 12 | void key_init(key_desc_t key); 13 | bool key_read(key_desc_t key); 14 | void key_press_callback_register(key_desc_t key, key_func_t func); 15 | 16 | #endif /* __KEY_H__ */ 17 | -------------------------------------------------------------------------------- /driver/key/key_desc.h: -------------------------------------------------------------------------------- 1 | #ifndef __KEY_DESC_H__ 2 | #define __KEY_DESC_H__ 3 | 4 | #include 5 | #include "stm32f4xx.h" 6 | #include "key.h" 7 | 8 | struct key_desc 9 | { 10 | GPIO_TypeDef *port; 11 | uint16_t pin; 12 | uint8_t exti_port_src; 13 | uint8_t exti_pin_src; 14 | uint32_t exti_line; 15 | uint8_t irqn; 16 | key_func_t func; 17 | }; 18 | 19 | #endif /* __KEY_H__ */ 20 | -------------------------------------------------------------------------------- /driver/tim_delay/tim_delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __TIM_DELAY_H__ 2 | #define __TIM_DELAY_H__ 3 | 4 | #include 5 | 6 | typedef void (*tim_periodic_callback_t)(void); 7 | 8 | void tim_delay_init(void); 9 | uint64_t tim_now(void); 10 | uint64_t tim_get_us(void); 11 | uint64_t tim_get_ms(void); 12 | void tim_delay_us(uint32_t us); 13 | void tim_delay_ms(uint32_t ms); 14 | void tim_register_periodic_callback(tim_periodic_callback_t callback); 15 | 16 | #endif /* __TIM_DELAY_H__ */ 17 | -------------------------------------------------------------------------------- /driver/rtc/rtc.h: -------------------------------------------------------------------------------- 1 | #ifndef __RTC_H__ 2 | #define __RTC_H__ 3 | 4 | #include 5 | 6 | typedef struct 7 | { 8 | uint16_t year; 9 | uint8_t month; 10 | uint8_t day; 11 | uint8_t hour; 12 | uint8_t minute; 13 | uint8_t second; 14 | uint8_t weekday; 15 | } rtc_date_time_t; 16 | 17 | void rtc_init(void); 18 | void rtc_set_time(const rtc_date_time_t *date_time); 19 | void rtc_get_time(rtc_date_time_t *date_time); 20 | 21 | #endif /* __RTC_H__ */ 22 | -------------------------------------------------------------------------------- /app/page/error_page.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ui.h" 4 | 5 | void error_page_display(const char *msg) 6 | { 7 | const uint16_t color_bg = mkcolor(0, 0, 0); 8 | ui_fill_color(0, 0, UI_WIDTH - 1, UI_HEIGHT - 1, color_bg); 9 | ui_draw_image(40, 37, &img_error); 10 | 11 | uint16_t startx = 0; 12 | int len = strlen(msg) * font20_maple_bold.size / 2; 13 | if (len < UI_WIDTH) 14 | startx = (UI_WIDTH - len + 1) / 2; 15 | ui_write_string(startx, 245, msg, mkcolor(255, 255, 0), color_bg, &font20_maple_bold); 16 | } 17 | -------------------------------------------------------------------------------- /driver/st7789/st7789.h: -------------------------------------------------------------------------------- 1 | #ifndef __ST7789_H__ 2 | #define __ST7789_H__ 3 | 4 | #include 5 | #include 6 | #include "font.h" 7 | #include "image.h" 8 | 9 | #define ST7789_WIDTH 240 10 | #define ST7789_HEIGHT 320 11 | 12 | void st7789_init(void); 13 | void st7789_fill_color(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color); 14 | void st7789_write_string(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bg_color, const font_t *font); 15 | void st7789_draw_image(uint16_t x, uint16_t y, const image_t *image); 16 | 17 | #endif /* __ST7789_H__ */ 18 | -------------------------------------------------------------------------------- /app/ui.h: -------------------------------------------------------------------------------- 1 | #ifndef __APP_UI_H__ 2 | #define __APP_UI_H__ 3 | 4 | #include 5 | #include "font.h" 6 | #include "image.h" 7 | 8 | #define UI_WIDTH 240 9 | #define UI_HEIGHT 320 10 | 11 | #define mkcolor(r, g, b) (((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)) 12 | 13 | void ui_init(void); 14 | void ui_fill_color(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color); 15 | void ui_write_string(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bg_color, const font_t *font); 16 | void ui_draw_image(uint16_t x, uint16_t y, const image_t *image); 17 | 18 | #endif /* __APP_UI_H__ */ 19 | -------------------------------------------------------------------------------- /app/page/page.h: -------------------------------------------------------------------------------- 1 | #ifndef __PAGE_H__ 2 | #define __PAGE_H__ 3 | 4 | #include "rtc.h" 5 | 6 | void welcome_page_display(void); 7 | void error_page_display(const char *msg); 8 | void wifi_page_display(void); 9 | void main_page_display(void); 10 | void main_page_redraw_wifi_ssid(const char *ssid); 11 | void main_page_redraw_time(rtc_date_time_t *time); 12 | void main_page_redraw_date(rtc_date_time_t *date); 13 | void main_page_redraw_inner_temperature(float temperature); 14 | void main_page_redraw_inner_humidity(float humidity); 15 | void main_page_redraw_outdoor_city(const char *city); 16 | void main_page_redraw_outdoor_temperature(float temperature); 17 | void main_page_redraw_outdoor_weather_icon(const int code); 18 | 19 | #endif /* __PAGE_H__ */ 20 | -------------------------------------------------------------------------------- /app/image/image.h: -------------------------------------------------------------------------------- 1 | #ifndef __IMAGE_H__ 2 | #define __IMAGE_H__ 3 | 4 | #include 5 | 6 | typedef struct 7 | { 8 | uint16_t width; 9 | uint16_t height; 10 | const uint8_t *data; 11 | } image_t; 12 | 13 | extern const image_t img_meihua; 14 | extern const image_t img_error; 15 | extern const image_t img_wifi; 16 | extern const image_t icon_wenduji; 17 | extern const image_t icon_wifi; 18 | extern const image_t icon_duoyun; 19 | extern const image_t icon_leizhenyu; 20 | extern const image_t icon_qing; 21 | extern const image_t icon_yintian; 22 | extern const image_t icon_yueliang; 23 | extern const image_t icon_zhongxue; 24 | extern const image_t icon_zhongyu; 25 | extern const image_t icon_na; 26 | 27 | #endif /* __IMAGE_H__ */ 28 | -------------------------------------------------------------------------------- /app/main.c: -------------------------------------------------------------------------------- 1 | #include "FreeRTOS.h" 2 | #include "task.h" 3 | #include "workqueue.h" 4 | #include "app.h" 5 | #include "ui.h" 6 | #include "wifi.h" 7 | #include "page.h" 8 | 9 | extern void board_lowlevel_init(void); 10 | extern void board_init(void); 11 | 12 | static void main_init(void *param) 13 | { 14 | board_init(); 15 | ui_init(); 16 | 17 | welcome_page_display(); 18 | 19 | wifi_init(); 20 | wifi_page_display(); 21 | wifi_wait_connect(); 22 | 23 | main_page_display(); 24 | app_init(); 25 | 26 | vTaskDelete(NULL); 27 | } 28 | 29 | int main(void) 30 | { 31 | board_lowlevel_init(); 32 | workqueue_init(); 33 | 34 | xTaskCreate(main_init, "init", 1024, NULL, 9, NULL); 35 | 36 | vTaskStartScheduler(); 37 | 38 | while (1) 39 | { 40 | ; // code should not run here 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /driver/esp_at/esp_at.h: -------------------------------------------------------------------------------- 1 | #ifndef __ESP_AT_H__ 2 | #define __ESP_AT_H__ 3 | 4 | #include 5 | #include 6 | 7 | typedef struct 8 | { 9 | char ssid[64]; 10 | char bssid[18]; 11 | int channel; 12 | int rssi; 13 | bool connected; 14 | } esp_wifi_info_t; 15 | 16 | typedef struct 17 | { 18 | uint16_t year; 19 | uint8_t month; 20 | uint8_t day; 21 | uint8_t hour; 22 | uint8_t minute; 23 | uint8_t second; 24 | uint8_t weekday; 25 | } esp_date_time_t; 26 | 27 | bool esp_at_init(void); 28 | bool esp_at_wifi_init(void); 29 | bool esp_at_connect_wifi(const char *ssid, const char *pwd, const char *mac); 30 | bool esp_at_get_wifi_info(esp_wifi_info_t *info); 31 | bool wifi_is_connected(void); 32 | bool esp_at_sntp_init(void); 33 | bool esp_at_sntp_get_time(esp_date_time_t *date); 34 | const char *esp_at_http_get(const char *url); 35 | 36 | #endif /* __ESP_AT_H__ */ 37 | -------------------------------------------------------------------------------- /app/font/font.h: -------------------------------------------------------------------------------- 1 | #ifndef __FONT_H 2 | #define __FONT_H 3 | 4 | // !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ 5 | 6 | #include 7 | 8 | typedef struct 9 | { 10 | const char *name; 11 | const uint8_t *model; 12 | } font_chinese_t; 13 | 14 | typedef struct 15 | { 16 | const uint8_t *ascii_model; 17 | const char *ascii_map; 18 | const font_chinese_t *chinese; 19 | uint16_t size; 20 | } font_t; 21 | 22 | extern const font_t font16_maple; 23 | extern const font_t font20_maple_bold; 24 | extern const font_t font24_maple_semibold; 25 | extern const font_t font24_maple_bold; 26 | extern const font_t font32_maple_bold; 27 | extern const font_t font54_maple_bold; 28 | extern const font_t font54_maple_semibold; 29 | extern const font_t font64_maple_extrabold; 30 | extern const font_t font76_maple_extrabold; 31 | 32 | #endif /* __FONT_H */ 33 | -------------------------------------------------------------------------------- /app/workqueue.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "FreeRTOS.h" 3 | #include "task.h" 4 | #include "queue.h" 5 | #include "workqueue.h" 6 | 7 | typedef struct 8 | { 9 | work_t work; 10 | void *param; 11 | } work_message_t; 12 | 13 | static QueueHandle_t work_msg_queue; 14 | 15 | static void work_func(void *param) 16 | { 17 | work_message_t msg; 18 | 19 | while (1) 20 | { 21 | xQueueReceive(work_msg_queue, &msg, portMAX_DELAY); 22 | msg.work(msg.param); 23 | } 24 | } 25 | 26 | void workqueue_init(void) 27 | { 28 | work_msg_queue = xQueueCreate(16, sizeof(work_message_t)); 29 | configASSERT(work_msg_queue); 30 | xTaskCreate(work_func, "workqueue", 1024, NULL, 5, NULL); 31 | } 32 | 33 | void workqueue_run(work_t work, void *param) 34 | { 35 | configASSERT(work_msg_queue); 36 | work_message_t msg = { work, param }; 37 | xQueueSend(work_msg_queue, &msg, portMAX_DELAY); 38 | } 39 | -------------------------------------------------------------------------------- /driver/led/led.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "led_desc.h" 4 | #include "led.h" 5 | 6 | void led_init(led_desc_t led) 7 | { 8 | GPIO_InitTypeDef GPIO_InitStructure; 9 | 10 | GPIO_StructInit(&GPIO_InitStructure); 11 | GPIO_InitStructure.GPIO_Pin = led->Pin; 12 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; 13 | GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; 14 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; 15 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; 16 | GPIO_Init(led->Port, &GPIO_InitStructure); 17 | 18 | GPIO_WriteBit(led->Port, led->Pin, led->OffBit); 19 | } 20 | 21 | void led_set(led_desc_t led, bool onoff) 22 | { 23 | GPIO_WriteBit(led->Port, led->Pin, onoff ? led->OnBit : led->OffBit); 24 | } 25 | 26 | void led_on(led_desc_t led) 27 | { 28 | GPIO_WriteBit(led->Port, led->Pin, led->OnBit); 29 | } 30 | 31 | void led_off(led_desc_t led) 32 | { 33 | GPIO_WriteBit(led->Port, led->Pin, led->OffBit); 34 | } 35 | -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "WeatherClock", 5 | "includePath": [ 6 | "app", 7 | "app/font", 8 | "app/image", 9 | "app/page", 10 | "driver/tim_delay", 11 | "driver/rtc", 12 | "driver/console", 13 | "driver/aht20", 14 | "driver/st7789", 15 | "driver/esp_at", 16 | "firmware/cmsis/core", 17 | "firmware/cmsis/device", 18 | "firmware/driver/inc", 19 | "third_lib/freertos/include", 20 | "third_lib/freertos/portable" 21 | ], 22 | "defines": [ 23 | "STM32F40_41xxx", 24 | "USE_STDPERIPH_DRIVER", 25 | "HSE_VALUE=8000000" 26 | ], 27 | "windowsSdkVersion": "10.0.26100.0", 28 | "compilerPath": "C:/Users/yuanx/Documents/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gcc.exe", 29 | "cStandard": "c99", 30 | "cppStandard": "c++11", 31 | "intelliSenseMode": "windows-gcc-arm", 32 | "browse": { 33 | "limitSymbolsToIncludedHeaders": true 34 | } 35 | } 36 | ], 37 | "version": 4 38 | } 39 | -------------------------------------------------------------------------------- /app/wifi.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "FreeRTOS.h" 4 | #include "task.h" 5 | #include "esp_at.h" 6 | #include "page.h" 7 | #include "wifi.h" 8 | 9 | void wifi_init(void) 10 | { 11 | if (!esp_at_init()) 12 | { 13 | printf("[AT] init failed\n"); 14 | goto err; 15 | } 16 | printf("[AT] inited\n"); 17 | 18 | if (!esp_at_wifi_init()) 19 | { 20 | printf("[WIFI] init failed\n"); 21 | goto err; 22 | } 23 | printf("[WIFI] inited\n"); 24 | 25 | if (!esp_at_sntp_init()) 26 | { 27 | printf("[SNTP] init failed\n"); 28 | goto err; 29 | } 30 | printf("[SNTP] inited\n"); 31 | 32 | return; 33 | 34 | err: 35 | error_page_display("wireless init failed"); 36 | while (1) 37 | { 38 | ; 39 | } 40 | } 41 | 42 | void wifi_wait_connect(void) 43 | { 44 | printf("[WIFI] connecting\n"); 45 | 46 | esp_at_connect_wifi(WIFI_SSID, WIFI_PASSWD, NULL); 47 | 48 | for (uint32_t t = 0; t < 10 * 1000; t += 100) 49 | { 50 | vTaskDelay(pdMS_TO_TICKS(100)); 51 | esp_wifi_info_t wifi = { 0 }; 52 | if (esp_at_get_wifi_info(&wifi) && wifi.connected) 53 | { 54 | printf("[WIFI] Connected\n"); 55 | printf("[WIFI] SSID: %s, BSSID: %s, Channel: %d, RSSI: %d\n", 56 | wifi.ssid, wifi.bssid, wifi.channel, wifi.rssi); 57 | return; 58 | } 59 | } 60 | 61 | printf("[WIFI] Connection Timeout\n"); 62 | error_page_display("wireless connect failed"); 63 | while (1) 64 | { 65 | ; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/weather.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "weather.h" 7 | 8 | bool parse_seniverse_response(const char *response, weather_info_t *info) 9 | { 10 | response = strstr(response, "\"results\":"); 11 | if (response == NULL) 12 | return false; 13 | 14 | const char *location_response = strstr(response, "\"location\":"); 15 | if (location_response == NULL) 16 | return false; 17 | 18 | const char *loaction_name_response = strstr(location_response, "\"name\":"); 19 | if (loaction_name_response) 20 | { 21 | sscanf(loaction_name_response, "\"name\": \"%31[^\"]\"", info->city); 22 | } 23 | 24 | const char *loaction_path_response = strstr(location_response, "\"path\":"); 25 | if (loaction_path_response) 26 | { 27 | sscanf(loaction_path_response, "\"path\": \"%128[^\"]\"", info->loaction); 28 | } 29 | 30 | const char *now_response = strstr(response, "\"now\":"); 31 | if (now_response == NULL) 32 | return false; 33 | 34 | const char *now_text_response = strstr(now_response, "\"text\":"); 35 | if (now_text_response) 36 | { 37 | sscanf(now_text_response, "\"text\": \"%15[^\"]\"", info->weather); 38 | } 39 | 40 | const char *now_code_response = strstr(now_response, "\"code\":"); 41 | if (now_code_response) 42 | { 43 | sscanf(now_code_response, "\"code\": \"%d\"", &info->weather_code); 44 | } 45 | 46 | char temperature_str[16] = { 0 }; 47 | const char *now_temperature_response = strstr(now_response, "\"temperature\":"); 48 | if (now_temperature_response) 49 | { 50 | if (sscanf(now_temperature_response, "\"temperature\": \"%15[^\"]\"", temperature_str) == 1) 51 | info->temperature = atof(temperature_str); 52 | } 53 | 54 | return true; 55 | } 56 | -------------------------------------------------------------------------------- /firmware/cmsis/device/stm32f4xx_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/STM32F4xx_StdPeriph_Templates/stm32f4xx_it.h 4 | * @author MCD Application Team 5 | * @version V1.8.1 6 | * @date 27-January-2022 7 | * @brief This file contains the headers of the interrupt handlers. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * Copyright (c) 2016 STMicroelectronics. 12 | * All rights reserved. 13 | * 14 | * This software is licensed under terms that can be found in the LICENSE file 15 | * in the root directory of this software component. 16 | * If no LICENSE file comes with this software, it is provided AS-IS. 17 | * 18 | ****************************************************************************** 19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F4xx_IT_H 23 | #define __STM32F4xx_IT_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32f4xx.h" 31 | 32 | /* Exported types ------------------------------------------------------------*/ 33 | /* Exported constants --------------------------------------------------------*/ 34 | /* Exported macro ------------------------------------------------------------*/ 35 | /* Exported functions ------------------------------------------------------- */ 36 | 37 | void NMI_Handler(void); 38 | void HardFault_Handler(void); 39 | void MemManage_Handler(void); 40 | void BusFault_Handler(void); 41 | void UsageFault_Handler(void); 42 | void SVC_Handler(void); 43 | void DebugMon_Handler(void); 44 | void PendSV_Handler(void); 45 | void SysTick_Handler(void); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* __STM32F4xx_IT_H */ 52 | 53 | -------------------------------------------------------------------------------- /app/board.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "FreeRTOS.h" 4 | #include "task.h" 5 | #include "stm32f4xx.h" 6 | #include "tim_delay.h" 7 | #include "console.h" 8 | #include "rtc.h" 9 | #include "aht20.h" 10 | 11 | void board_lowlevel_init(void) 12 | { 13 | RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); 14 | RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE); 15 | RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); 16 | RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); 17 | RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE); 18 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); 19 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); 20 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C2, ENABLE); 21 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE); 22 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE); 23 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); 24 | RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA1, ENABLE); 25 | RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE); 26 | PWR_BackupAccessCmd(ENABLE); 27 | RCC_LSEConfig(RCC_LSE_ON); 28 | while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET); 29 | RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); 30 | } 31 | 32 | void board_init(void) 33 | { 34 | tim_delay_init(); 35 | console_init(); 36 | printf("[SYS] Build Date: %s %s\n", __DATE__, __TIME__); 37 | 38 | rtc_init(); 39 | aht20_init(); 40 | } 41 | 42 | int fputc(int ch, FILE *f) 43 | { 44 | USART_SendData(USART1, (uint8_t)ch); 45 | while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET); 46 | return ch; 47 | } 48 | 49 | void vAssertCalled(const char *file, int line) 50 | { 51 | portDISABLE_INTERRUPTS(); 52 | printf("Assert Called: %s(%d)\n", file, line); 53 | } 54 | 55 | void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName) 56 | { 57 | printf("Stack Overflowed: %s\n", pcTaskName); 58 | configASSERT(0); 59 | } 60 | 61 | void vApplicationMallocFailedHook(void) 62 | { 63 | printf("Malloc Failed\n"); 64 | configASSERT(0); 65 | } 66 | -------------------------------------------------------------------------------- /firmware/cmsis/device/system_stm32f4xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f4xx.h 4 | * @author MCD Application Team 5 | * @version V1.8.1 6 | * @date 27-January-2022 7 | * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * Copyright (c) 2016 STMicroelectronics. 12 | * All rights reserved. 13 | * 14 | * This software is licensed under terms that can be found in the LICENSE file 15 | * in the root directory of this software component. 16 | * If no LICENSE file comes with this software, it is provided AS-IS. 17 | * 18 | ****************************************************************************** 19 | */ 20 | 21 | /** @addtogroup CMSIS 22 | * @{ 23 | */ 24 | 25 | /** @addtogroup stm32f4xx_system 26 | * @{ 27 | */ 28 | 29 | /** 30 | * @brief Define to prevent recursive inclusion 31 | */ 32 | #ifndef __SYSTEM_STM32F4XX_H 33 | #define __SYSTEM_STM32F4XX_H 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** @addtogroup STM32F4xx_System_Includes 40 | * @{ 41 | */ 42 | 43 | /** 44 | * @} 45 | */ 46 | 47 | 48 | /** @addtogroup STM32F4xx_System_Exported_types 49 | * @{ 50 | */ 51 | 52 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 53 | 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @addtogroup STM32F4xx_System_Exported_Constants 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @addtogroup STM32F4xx_System_Exported_Macros 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @addtogroup STM32F4xx_System_Exported_Functions 76 | * @{ 77 | */ 78 | 79 | extern void SystemInit(void); 80 | extern void SystemCoreClockUpdate(void); 81 | /** 82 | * @} 83 | */ 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif /*__SYSTEM_STM32F4XX_H */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | -------------------------------------------------------------------------------- /driver/rtc/rtc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "stm32f4xx.h" 3 | #include "rtc.h" 4 | 5 | void rtc_init(void) 6 | { 7 | RTC_InitTypeDef RTC_InitStruct; 8 | RTC_StructInit(&RTC_InitStruct); 9 | RTC_Init(&RTC_InitStruct); 10 | 11 | RCC_RTCCLKCmd(ENABLE); 12 | RTC_WaitForSynchro(); 13 | } 14 | 15 | static void _rtc_set_time_once(const rtc_date_time_t *date_time) 16 | { 17 | RTC_DateTypeDef date; 18 | RTC_TimeTypeDef time; 19 | 20 | RTC_DateStructInit(&date); 21 | RTC_TimeStructInit(&time); 22 | 23 | date.RTC_Year = date_time->year - 2000; 24 | date.RTC_Month = date_time->month; 25 | date.RTC_Date = date_time->day; 26 | date.RTC_WeekDay = date_time->weekday; 27 | time.RTC_Hours = date_time->hour; 28 | time.RTC_Minutes = date_time->minute; 29 | time.RTC_Seconds = date_time->second; 30 | 31 | RTC_SetDate(RTC_Format_BIN, &date); 32 | RTC_SetTime(RTC_Format_BIN, &time); 33 | 34 | } 35 | 36 | static void _rtc_get_time_once(rtc_date_time_t *date_time) 37 | { 38 | RTC_DateTypeDef date; 39 | RTC_TimeTypeDef time; 40 | 41 | RTC_DateStructInit(&date); 42 | RTC_TimeStructInit(&time); 43 | 44 | RTC_GetDate(RTC_Format_BIN, &date); 45 | RTC_GetTime(RTC_Format_BIN, &time); 46 | 47 | date_time->year = 2000 + date.RTC_Year; 48 | date_time->month = date.RTC_Month; 49 | date_time->day = date.RTC_Date; 50 | date_time->weekday = date.RTC_WeekDay; 51 | date_time->hour = time.RTC_Hours; 52 | date_time->minute = time.RTC_Minutes; 53 | date_time->second = time.RTC_Seconds; 54 | } 55 | 56 | void rtc_set_time(const rtc_date_time_t *date_time) 57 | { 58 | rtc_date_time_t rtime; 59 | do { 60 | _rtc_set_time_once(date_time); 61 | _rtc_get_time_once(&rtime); 62 | } while (date_time->second != rtime.second); 63 | } 64 | 65 | void rtc_get_time(rtc_date_time_t *date_time) 66 | { 67 | rtc_date_time_t time1, time2; 68 | do { 69 | _rtc_get_time_once(&time1); 70 | _rtc_get_time_once(&time2); 71 | } while (memcmp(&time1, &time2, sizeof(rtc_date_time_t)) != 0); 72 | 73 | memcpy(date_time, &time1, sizeof(rtc_date_time_t)); 74 | } 75 | -------------------------------------------------------------------------------- /firmware/driver/inc/stm32f4xx_crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_crc.h 4 | * @author MCD Application Team 5 | * @version V1.8.1 6 | * @date 27-January-2022 7 | * @brief This file contains all the functions prototypes for the CRC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * Copyright (c) 2016 STMicroelectronics. 13 | * All rights reserved. 14 | * 15 | * This software is licensed under terms that can be found in the LICENSE file 16 | * in the root directory of this software component. 17 | * If no LICENSE file comes with this software, it is provided AS-IS. 18 | * 19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F4xx_CRC_H 24 | #define __STM32F4xx_CRC_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f4xx.h" 32 | 33 | /** @addtogroup STM32F4xx_StdPeriph_Driver 34 | * @{ 35 | */ 36 | 37 | /** @addtogroup CRC 38 | * @{ 39 | */ 40 | 41 | /* Exported types ------------------------------------------------------------*/ 42 | /* Exported constants --------------------------------------------------------*/ 43 | 44 | /** @defgroup CRC_Exported_Constants 45 | * @{ 46 | */ 47 | 48 | /** 49 | * @} 50 | */ 51 | 52 | /* Exported macro ------------------------------------------------------------*/ 53 | /* Exported functions --------------------------------------------------------*/ 54 | 55 | void CRC_ResetDR(void); 56 | uint32_t CRC_CalcCRC(uint32_t Data); 57 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength); 58 | uint32_t CRC_GetCRC(void); 59 | void CRC_SetIDRegister(uint8_t IDValue); 60 | uint8_t CRC_GetIDRegister(void); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* __STM32F4xx_CRC_H */ 67 | 68 | /** 69 | * @} 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | -------------------------------------------------------------------------------- /driver/tim_delay/tim_delay.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "stm32f4xx.h" 4 | #include "tim_delay.h" 5 | 6 | static volatile uint64_t tim_tick_count; 7 | static tim_periodic_callback_t periodic_callback; 8 | 9 | void tim_delay_init(void) 10 | { 11 | RCC_ClocksTypeDef RCC_ClocksStruct; 12 | RCC_GetClocksFreq(&RCC_ClocksStruct); 13 | uint32_t apb1_tim_freq_mhz = RCC_ClocksStruct.PCLK1_Frequency / 1000 / 1000 * 2; 14 | 15 | TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; 16 | TIM_TimeBaseStructInit(&TIM_TimeBaseStructure); 17 | TIM_TimeBaseStructure.TIM_Prescaler = apb1_tim_freq_mhz - 1; 18 | TIM_TimeBaseStructure.TIM_Period = 999; 19 | TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; 20 | TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; 21 | TIM_TimeBaseInit(TIM6, &TIM_TimeBaseStructure); 22 | TIM_ITConfig(TIM6, TIM_IT_Update, ENABLE); 23 | TIM_Cmd(TIM6, ENABLE); 24 | 25 | NVIC_InitTypeDef NVIC_InitStructure; 26 | NVIC_InitStructure.NVIC_IRQChannel = TIM6_DAC_IRQn; 27 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 5; 28 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; 29 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 30 | NVIC_Init(&NVIC_InitStructure); 31 | } 32 | 33 | uint64_t tim_now(void) 34 | { 35 | uint64_t now, last_count; 36 | do { 37 | last_count = tim_tick_count; 38 | now = tim_tick_count + TIM_GetCounter(TIM6); 39 | } while (last_count != tim_tick_count); 40 | return now; 41 | } 42 | 43 | uint64_t tim_get_us(void) 44 | { 45 | return tim_now(); 46 | } 47 | 48 | uint64_t cpu_get_ms(void) 49 | { 50 | return tim_now() / 1000; 51 | } 52 | 53 | void tim_delay_us(uint32_t us) 54 | { 55 | uint64_t now = tim_now(); 56 | while (tim_now() - now < (uint64_t)us); 57 | } 58 | 59 | void tim_delay_ms(uint32_t ms) 60 | { 61 | uint64_t now = tim_now(); 62 | while (tim_now() - now < (uint64_t)ms * 1000); 63 | } 64 | 65 | void tim_register_periodic_callback(tim_periodic_callback_t callback) 66 | { 67 | periodic_callback = callback; 68 | } 69 | 70 | void TIM6_DAC_IRQHandler(void) 71 | { 72 | if (TIM_GetITStatus(TIM6, TIM_IT_Update) != RESET) 73 | { 74 | TIM_ClearITPendingBit(TIM6, TIM_IT_Update); 75 | tim_tick_count += 1000; 76 | if (periodic_callback) 77 | periodic_callback(); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /firmware/driver/inc/stm32f4xx_flash_ramfunc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_flash_ramfunc.h 4 | * @author MCD Application Team 5 | * @version V1.8.1 6 | * @date 27-January-2022 7 | * @brief Header file of FLASH RAMFUNC driver. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * Copyright (c) 2016 STMicroelectronics. 12 | * All rights reserved. 13 | * 14 | * This software is licensed under terms that can be found in the LICENSE file 15 | * in the root directory of this software component. 16 | * If no LICENSE file comes with this software, it is provided AS-IS. 17 | * 18 | ****************************************************************************** 19 | */ 20 | 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F4xx_FLASH_RAMFUNC_H 24 | #define __STM32F4xx_FLASH_RAMFUNC_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f4xx.h" 32 | 33 | /** @addtogroup STM32F4xx_StdPeriph_Driver 34 | * @{ 35 | */ 36 | 37 | /** @addtogroup FLASH RAMFUNC 38 | * @{ 39 | */ 40 | 41 | /* Exported types ------------------------------------------------------------*/ 42 | /* Private define ------------------------------------------------------------*/ 43 | /** 44 | * @brief __RAM_FUNC definition 45 | */ 46 | #if defined ( __CC_ARM ) 47 | /* ARM Compiler 48 | ------------ 49 | RAM functions are defined using the toolchain options. 50 | Functions that are executed in RAM should reside in a separate source module. 51 | Using the 'Options for File' dialog you can simply change the 'Code / Const' 52 | area of a module to a memory space in physical RAM. 53 | Available memory areas are declared in the 'Target' tab of the 'Options for Target' 54 | dialog. 55 | */ 56 | #define __RAM_FUNC void 57 | 58 | #elif defined ( __ICCARM__ ) 59 | /* ICCARM Compiler 60 | --------------- 61 | RAM functions are defined using a specific toolchain keyword "__ramfunc". 62 | */ 63 | #define __RAM_FUNC __ramfunc void 64 | 65 | #elif defined ( __GNUC__ ) 66 | /* GNU Compiler 67 | ------------ 68 | RAM functions are defined using a specific toolchain attribute 69 | "__attribute__((section(".RamFunc")))". 70 | */ 71 | #define __RAM_FUNC void __attribute__((section(".RamFunc"))) 72 | 73 | #endif 74 | /* Exported constants --------------------------------------------------------*/ 75 | /* Exported macro ------------------------------------------------------------*/ 76 | /* Exported functions --------------------------------------------------------*/ 77 | __RAM_FUNC FLASH_FlashInterfaceCmd(FunctionalState NewState); 78 | __RAM_FUNC FLASH_FlashSleepModeCmd(FunctionalState NewState); 79 | 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif /* __STM32F4xx_FLASH_RAMFUNC_H */ 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | 96 | -------------------------------------------------------------------------------- /firmware/driver/inc/stm32f4xx_wwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_wwdg.h 4 | * @author MCD Application Team 5 | * @version V1.8.1 6 | * @date 27-January-2022 7 | * @brief This file contains all the functions prototypes for the WWDG firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * Copyright (c) 2016 STMicroelectronics. 13 | * All rights reserved. 14 | * 15 | * This software is licensed under terms that can be found in the LICENSE file 16 | * in the root directory of this software component. 17 | * If no LICENSE file comes with this software, it is provided AS-IS. 18 | * 19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F4xx_WWDG_H 24 | #define __STM32F4xx_WWDG_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f4xx.h" 32 | 33 | /** @addtogroup STM32F4xx_StdPeriph_Driver 34 | * @{ 35 | */ 36 | 37 | /** @addtogroup WWDG 38 | * @{ 39 | */ 40 | 41 | /* Exported types ------------------------------------------------------------*/ 42 | /* Exported constants --------------------------------------------------------*/ 43 | 44 | /** @defgroup WWDG_Exported_Constants 45 | * @{ 46 | */ 47 | 48 | /** @defgroup WWDG_Prescaler 49 | * @{ 50 | */ 51 | 52 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000) 53 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080) 54 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100) 55 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180) 56 | #define IS_WWDG_PRESCALER(PRESCALER) (((PRESCALER) == WWDG_Prescaler_1) || \ 57 | ((PRESCALER) == WWDG_Prescaler_2) || \ 58 | ((PRESCALER) == WWDG_Prescaler_4) || \ 59 | ((PRESCALER) == WWDG_Prescaler_8)) 60 | #define IS_WWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0x7F) 61 | #define IS_WWDG_COUNTER(COUNTER) (((COUNTER) >= 0x40) && ((COUNTER) <= 0x7F)) 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** 68 | * @} 69 | */ 70 | 71 | /* Exported macro ------------------------------------------------------------*/ 72 | /* Exported functions --------------------------------------------------------*/ 73 | 74 | /* Function used to set the WWDG configuration to the default reset state ****/ 75 | void WWDG_DeInit(void); 76 | 77 | /* Prescaler, Refresh window and Counter configuration functions **************/ 78 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler); 79 | void WWDG_SetWindowValue(uint8_t WindowValue); 80 | void WWDG_EnableIT(void); 81 | void WWDG_SetCounter(uint8_t Counter); 82 | 83 | /* WWDG activation function ***************************************************/ 84 | void WWDG_Enable(uint8_t Counter); 85 | 86 | /* Interrupts and flags management functions **********************************/ 87 | FlagStatus WWDG_GetFlagStatus(void); 88 | void WWDG_ClearFlag(void); 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif /* __STM32F4xx_WWDG_H */ 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | -------------------------------------------------------------------------------- /firmware/driver/src/stm32f4xx_crc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_crc.c 4 | * @author MCD Application Team 5 | * @version V1.8.1 6 | * @date 27-January-2022 7 | * @brief This file provides all the CRC firmware functions. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * Copyright (c) 2016 STMicroelectronics. 12 | * All rights reserved. 13 | * 14 | * This software is licensed under terms that can be found in the LICENSE file 15 | * in the root directory of this software component. 16 | * If no LICENSE file comes with this software, it is provided AS-IS. 17 | * 18 | ****************************************************************************** 19 | */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "stm32f4xx_crc.h" 23 | 24 | /** @addtogroup STM32F4xx_StdPeriph_Driver 25 | * @{ 26 | */ 27 | 28 | /** @defgroup CRC 29 | * @brief CRC driver modules 30 | * @{ 31 | */ 32 | 33 | /* Private typedef -----------------------------------------------------------*/ 34 | /* Private define ------------------------------------------------------------*/ 35 | /* Private macro -------------------------------------------------------------*/ 36 | /* Private variables ---------------------------------------------------------*/ 37 | /* Private function prototypes -----------------------------------------------*/ 38 | /* Private functions ---------------------------------------------------------*/ 39 | 40 | /** @defgroup CRC_Private_Functions 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Resets the CRC Data register (DR). 46 | * @param None 47 | * @retval None 48 | */ 49 | void CRC_ResetDR(void) 50 | { 51 | /* Reset CRC generator */ 52 | CRC->CR = CRC_CR_RESET; 53 | } 54 | 55 | /** 56 | * @brief Computes the 32-bit CRC of a given data word(32-bit). 57 | * @param Data: data word(32-bit) to compute its CRC 58 | * @retval 32-bit CRC 59 | */ 60 | uint32_t CRC_CalcCRC(uint32_t Data) 61 | { 62 | CRC->DR = Data; 63 | 64 | return (CRC->DR); 65 | } 66 | 67 | /** 68 | * @brief Computes the 32-bit CRC of a given buffer of data word(32-bit). 69 | * @param pBuffer: pointer to the buffer containing the data to be computed 70 | * @param BufferLength: length of the buffer to be computed 71 | * @retval 32-bit CRC 72 | */ 73 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength) 74 | { 75 | uint32_t index = 0; 76 | 77 | for(index = 0; index < BufferLength; index++) 78 | { 79 | CRC->DR = pBuffer[index]; 80 | } 81 | return (CRC->DR); 82 | } 83 | 84 | /** 85 | * @brief Returns the current CRC value. 86 | * @param None 87 | * @retval 32-bit CRC 88 | */ 89 | uint32_t CRC_GetCRC(void) 90 | { 91 | return (CRC->DR); 92 | } 93 | 94 | /** 95 | * @brief Stores a 8-bit data in the Independent Data(ID) register. 96 | * @param IDValue: 8-bit value to be stored in the ID register 97 | * @retval None 98 | */ 99 | void CRC_SetIDRegister(uint8_t IDValue) 100 | { 101 | CRC->IDR = IDValue; 102 | } 103 | 104 | /** 105 | * @brief Returns the 8-bit data stored in the Independent Data(ID) register 106 | * @param None 107 | * @retval 8-bit value of the ID register 108 | */ 109 | uint8_t CRC_GetIDRegister(void) 110 | { 111 | return (CRC->IDR); 112 | } 113 | 114 | /** 115 | * @} 116 | */ 117 | 118 | /** 119 | * @} 120 | */ 121 | 122 | /** 123 | * @} 124 | */ 125 | 126 | -------------------------------------------------------------------------------- /tools/convert_chinese_font.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Chinese font conversion script 5 | Convert font data from chinese.txt to C struct array format 6 | """ 7 | 8 | import re 9 | import os 10 | 11 | def parse_chinese_txt(file_path): 12 | """ 13 | Parse chinese.txt file, extract character names and font data 14 | """ 15 | characters = [] 16 | with open(file_path, 'r', encoding='gb2312') as f: 17 | content = f.read() 18 | 19 | # Match pattern: hex data followed by /*"character",index*/ 20 | # The format is: hex_data/*"char_name",index*/ 21 | pattern = r'((?:0x[0-9A-Fa-f]{2},?\s*)+)/\*"([^"]+)",\d+\*/' 22 | 23 | matches = re.findall(pattern, content) 24 | 25 | for hex_text, char_name in matches: 26 | # Extract hex data 27 | hex_data = extract_hex_data(hex_text) 28 | if hex_data: 29 | characters.append({ 30 | 'name': char_name.strip(), 31 | 'data': hex_data 32 | }) 33 | 34 | return characters 35 | 36 | def extract_hex_data(data_text): 37 | """ 38 | Extract hex data from text 39 | """ 40 | # Match all hex values (starting with 0x) 41 | hex_pattern = r'0x[0-9A-Fa-f]{2}' 42 | hex_matches = re.findall(hex_pattern, data_text) 43 | 44 | return hex_matches 45 | 46 | def format_hex_data(hex_data, bytes_per_line=16): 47 | """ 48 | Format hex data for multi-line display 49 | """ 50 | lines = [] 51 | for i in range(0, len(hex_data), bytes_per_line): 52 | line_data = hex_data[i:i + bytes_per_line] 53 | line = ' ' + ','.join(line_data) + ',' 54 | lines.append(line) 55 | 56 | return lines 57 | 58 | def generate_c_struct_array(characters, output_file): 59 | """ 60 | Generate C struct array code 61 | """ 62 | with open(output_file, 'w', encoding='utf-8') as f: 63 | f.write('static const font_chinese_t chinese_model[] =\n') 64 | f.write('{\n') 65 | 66 | for i, char in enumerate(characters): 67 | f.write(' {\n') 68 | f.write(f' .name = "{char["name"]}",\n') 69 | f.write(' .model = (const uint8_t[]) {\n') 70 | 71 | # Format hex data 72 | formatted_lines = format_hex_data(char['data']) 73 | for line in formatted_lines: 74 | f.write(line + '\n') 75 | 76 | f.write(' }\n') 77 | f.write(' },\n') 78 | 79 | # Add empty struct as end marker 80 | f.write(' {}\n') 81 | f.write('};\n\n') 82 | 83 | def main(): 84 | """ 85 | Main function 86 | """ 87 | # Input file path 88 | input_file = 'chinese.txt' 89 | # Output file path 90 | output_file = 'chinese_model.txt' 91 | 92 | # Check if input file exists 93 | if not os.path.exists(input_file): 94 | print(f"Error: Input file {input_file} not found") 95 | return 96 | 97 | try: 98 | # Parse input file 99 | print(f"Parsing file {input_file}...") 100 | characters = parse_chinese_txt(input_file) 101 | print(f"Successfully parsed {len(characters)} characters") 102 | 103 | # Generate output file 104 | print(f"Generating output file {output_file}...") 105 | generate_c_struct_array(characters, output_file) 106 | print(f"Successfully generated output file {output_file}") 107 | 108 | # Display parsed characters 109 | print("\nParsed characters:") 110 | for i, char in enumerate(characters): 111 | print(f" {i}: {char['name']} ({len(char['data'])} bytes)") 112 | 113 | except Exception as e: 114 | print(f"Error during processing: {e}") 115 | 116 | if __name__ == "__main__": 117 | main() 118 | -------------------------------------------------------------------------------- /firmware/cmsis/core/arm_const_structs.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 19. March 2015 5 | * $Revision: V.1.4.5 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_const_structs.h 9 | * 10 | * Description: This file has constant structs that are initialized for 11 | * user convenience. For example, some can be given as 12 | * arguments to the arm_cfft_f32() function. 13 | * 14 | * Target Processor: Cortex-M4/Cortex-M3 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions 18 | * are met: 19 | * - Redistributions of source code must retain the above copyright 20 | * notice, this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in 23 | * the documentation and/or other materials provided with the 24 | * distribution. 25 | * - Neither the name of ARM LIMITED nor the names of its contributors 26 | * may be used to endorse or promote products derived from this 27 | * software without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 32 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 33 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 35 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 40 | * POSSIBILITY OF SUCH DAMAGE. 41 | * -------------------------------------------------------------------- */ 42 | 43 | #ifndef _ARM_CONST_STRUCTS_H 44 | #define _ARM_CONST_STRUCTS_H 45 | 46 | #include "arm_math.h" 47 | #include "arm_common_tables.h" 48 | 49 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16; 50 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32; 51 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64; 52 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128; 53 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256; 54 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512; 55 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024; 56 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048; 57 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096; 58 | 59 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16; 60 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32; 61 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64; 62 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128; 63 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256; 64 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512; 65 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024; 66 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048; 67 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096; 68 | 69 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16; 70 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32; 71 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64; 72 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128; 73 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256; 74 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512; 75 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024; 76 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048; 77 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /app/ui.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "FreeRTOS.h" 5 | #include "task.h" 6 | #include "queue.h" 7 | #include "st7789.h" 8 | #include "ui.h" 9 | #include "font.h" 10 | #include "image.h" 11 | 12 | typedef enum 13 | { 14 | UI_ACTION_FILL_COLOR, 15 | UI_ACTION_WRITE_STRING, 16 | UI_ACTION_DRAW_IMAGE, 17 | } ui_action_t; 18 | 19 | typedef struct 20 | { 21 | ui_action_t action; 22 | union 23 | { 24 | struct 25 | { 26 | uint16_t x; 27 | uint16_t y; 28 | uint16_t width; 29 | uint16_t height; 30 | uint16_t color; 31 | } fill_color; 32 | struct 33 | { 34 | uint16_t x; 35 | uint16_t y; 36 | const char *str; 37 | uint16_t color; 38 | uint16_t bg_color; 39 | const font_t *font; 40 | } write_string; 41 | struct 42 | { 43 | uint16_t x; 44 | uint16_t y; 45 | const image_t *image; 46 | } draw_image; 47 | }; 48 | } ui_message_t; 49 | 50 | static QueueHandle_t ui_queue; 51 | 52 | static void ui_func(void *param) 53 | { 54 | ui_message_t msg; 55 | 56 | st7789_init(); 57 | 58 | while (1) 59 | { 60 | xQueueReceive(ui_queue, &msg, portMAX_DELAY); 61 | 62 | switch (msg.action) 63 | { 64 | case UI_ACTION_FILL_COLOR: 65 | st7789_fill_color(msg.fill_color.x, msg.fill_color.y, 66 | msg.fill_color.width, msg.fill_color.height, 67 | msg.fill_color.color); 68 | break; 69 | case UI_ACTION_WRITE_STRING: 70 | st7789_write_string(msg.write_string.x, msg.write_string.y, 71 | msg.write_string.str, 72 | msg.write_string.color, msg.write_string.bg_color, 73 | msg.write_string.font); 74 | vPortFree((void*)msg.write_string.str); 75 | break; 76 | case UI_ACTION_DRAW_IMAGE: 77 | st7789_draw_image(msg.draw_image.x, msg.draw_image.y, 78 | msg.draw_image.image); 79 | break; 80 | default: 81 | printf("Unknown UI action: %d\n", msg.action); 82 | break; 83 | } 84 | } 85 | } 86 | 87 | void ui_init(void) 88 | { 89 | ui_queue = xQueueCreate(16, sizeof(ui_message_t)); 90 | configASSERT(ui_queue); 91 | xTaskCreate(ui_func, "ui", 1024, NULL, 8, NULL); 92 | } 93 | 94 | void ui_fill_color(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) 95 | { 96 | ui_message_t msg; 97 | msg.action = UI_ACTION_FILL_COLOR; 98 | msg.fill_color.x = x; 99 | msg.fill_color.y = y; 100 | msg.fill_color.width = width; 101 | msg.fill_color.height = height; 102 | msg.fill_color.color = color; 103 | 104 | xQueueSend(ui_queue, &msg, portMAX_DELAY); 105 | } 106 | 107 | void ui_write_string(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bg_color, const font_t *font) 108 | { 109 | char *pstr = pvPortMalloc(strlen(str) + 1); 110 | if (pstr == NULL) 111 | { 112 | printf("ui write string malloc failed: %s", str); 113 | return; 114 | } 115 | strcpy(pstr, str); 116 | 117 | ui_message_t msg; 118 | msg.action = UI_ACTION_WRITE_STRING; 119 | msg.write_string.x = x; 120 | msg.write_string.y = y; 121 | msg.write_string.str = pstr; 122 | msg.write_string.color = color; 123 | msg.write_string.bg_color = bg_color; 124 | msg.write_string.font = font; 125 | 126 | xQueueSend(ui_queue, &msg, portMAX_DELAY); 127 | } 128 | 129 | void ui_draw_image(uint16_t x, uint16_t y, const image_t *image) 130 | { 131 | ui_message_t msg; 132 | msg.action = UI_ACTION_DRAW_IMAGE; 133 | msg.draw_image.x = x; 134 | msg.draw_image.y = y; 135 | msg.draw_image.image = image; 136 | 137 | xQueueSend(ui_queue, &msg, portMAX_DELAY); 138 | } 139 | -------------------------------------------------------------------------------- /firmware/driver/inc/stm32f4xx_dbgmcu.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_dbgmcu.h 4 | * @author MCD Application Team 5 | * @version V1.8.1 6 | * @date 27-January-2022 7 | * @brief This file contains all the functions prototypes for the DBGMCU firmware library. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * Copyright (c) 2016 STMicroelectronics. 12 | * All rights reserved. 13 | * 14 | * This software is licensed under terms that can be found in the LICENSE file 15 | * in the root directory of this software component. 16 | * If no LICENSE file comes with this software, it is provided AS-IS. 17 | * 18 | ****************************************************************************** 19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F4xx_DBGMCU_H 23 | #define __STM32F4xx_DBGMCU_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32f4xx.h" 31 | 32 | /** @addtogroup STM32F4xx_StdPeriph_Driver 33 | * @{ 34 | */ 35 | 36 | /** @addtogroup DBGMCU 37 | * @{ 38 | */ 39 | 40 | /* Exported types ------------------------------------------------------------*/ 41 | /* Exported constants --------------------------------------------------------*/ 42 | 43 | /** @defgroup DBGMCU_Exported_Constants 44 | * @{ 45 | */ 46 | #define DBGMCU_SLEEP ((uint32_t)0x00000001) 47 | #define DBGMCU_STOP ((uint32_t)0x00000002) 48 | #define DBGMCU_STANDBY ((uint32_t)0x00000004) 49 | #define IS_DBGMCU_PERIPH(PERIPH) ((((PERIPH) & 0xFFFFFFF8) == 0x00) && ((PERIPH) != 0x00)) 50 | 51 | #define DBGMCU_TIM2_STOP ((uint32_t)0x00000001) 52 | #define DBGMCU_TIM3_STOP ((uint32_t)0x00000002) 53 | #define DBGMCU_TIM4_STOP ((uint32_t)0x00000004) 54 | #define DBGMCU_TIM5_STOP ((uint32_t)0x00000008) 55 | #define DBGMCU_TIM6_STOP ((uint32_t)0x00000010) 56 | #define DBGMCU_TIM7_STOP ((uint32_t)0x00000020) 57 | #define DBGMCU_TIM12_STOP ((uint32_t)0x00000040) 58 | #define DBGMCU_TIM13_STOP ((uint32_t)0x00000080) 59 | #define DBGMCU_TIM14_STOP ((uint32_t)0x00000100) 60 | #define DBGMCU_RTC_STOP ((uint32_t)0x00000400) 61 | #define DBGMCU_WWDG_STOP ((uint32_t)0x00000800) 62 | #define DBGMCU_IWDG_STOP ((uint32_t)0x00001000) 63 | #define DBGMCU_I2C1_SMBUS_TIMEOUT ((uint32_t)0x00200000) 64 | #define DBGMCU_I2C2_SMBUS_TIMEOUT ((uint32_t)0x00400000) 65 | #define DBGMCU_I2C3_SMBUS_TIMEOUT ((uint32_t)0x00800000) 66 | #define DBGMCU_CAN1_STOP ((uint32_t)0x02000000) 67 | #define DBGMCU_CAN2_STOP ((uint32_t)0x04000000) 68 | #define IS_DBGMCU_APB1PERIPH(PERIPH) ((((PERIPH) & 0xF91FE200) == 0x00) && ((PERIPH) != 0x00)) 69 | 70 | #define DBGMCU_TIM1_STOP ((uint32_t)0x00000001) 71 | #define DBGMCU_TIM8_STOP ((uint32_t)0x00000002) 72 | #define DBGMCU_TIM9_STOP ((uint32_t)0x00010000) 73 | #define DBGMCU_TIM10_STOP ((uint32_t)0x00020000) 74 | #define DBGMCU_TIM11_STOP ((uint32_t)0x00040000) 75 | #define IS_DBGMCU_APB2PERIPH(PERIPH) ((((PERIPH) & 0xFFF8FFFC) == 0x00) && ((PERIPH) != 0x00)) 76 | /** 77 | * @} 78 | */ 79 | 80 | /* Exported macro ------------------------------------------------------------*/ 81 | /* Exported functions --------------------------------------------------------*/ 82 | uint32_t DBGMCU_GetREVID(void); 83 | uint32_t DBGMCU_GetDEVID(void); 84 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState); 85 | void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState); 86 | void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState); 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | #endif /* __STM32F4xx_DBGMCU_H */ 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | -------------------------------------------------------------------------------- /firmware/driver/inc/stm32f4xx_rng.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_rng.h 4 | * @author MCD Application Team 5 | * @version V1.8.1 6 | * @date 27-January-2022 7 | * @brief This file contains all the functions prototypes for the Random 8 | * Number Generator(RNG) firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * Copyright (c) 2016 STMicroelectronics. 13 | * All rights reserved. 14 | * 15 | * This software is licensed under terms that can be found in the LICENSE file 16 | * in the root directory of this software component. 17 | * If no LICENSE file comes with this software, it is provided AS-IS. 18 | * 19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F4xx_RNG_H 24 | #define __STM32F4xx_RNG_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f4xx.h" 32 | 33 | /** @addtogroup STM32F4xx_StdPeriph_Driver 34 | * @{ 35 | */ 36 | 37 | /** @addtogroup RNG 38 | * @{ 39 | */ 40 | #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F410xx) || defined(STM32F412xG) || defined(STM32F413_423xx) || defined(STM32F429_439xx) || defined(STM32F469_479xx) 41 | /* Exported types ------------------------------------------------------------*/ 42 | /* Exported constants --------------------------------------------------------*/ 43 | 44 | /** @defgroup RNG_Exported_Constants 45 | * @{ 46 | */ 47 | 48 | /** @defgroup RNG_flags_definition 49 | * @{ 50 | */ 51 | #define RNG_FLAG_DRDY ((uint8_t)0x0001) /*!< Data ready */ 52 | #define RNG_FLAG_CECS ((uint8_t)0x0002) /*!< Clock error current status */ 53 | #define RNG_FLAG_SECS ((uint8_t)0x0004) /*!< Seed error current status */ 54 | 55 | #define IS_RNG_GET_FLAG(RNG_FLAG) (((RNG_FLAG) == RNG_FLAG_DRDY) || \ 56 | ((RNG_FLAG) == RNG_FLAG_CECS) || \ 57 | ((RNG_FLAG) == RNG_FLAG_SECS)) 58 | #define IS_RNG_CLEAR_FLAG(RNG_FLAG) (((RNG_FLAG) == RNG_FLAG_CECS) || \ 59 | ((RNG_FLAG) == RNG_FLAG_SECS)) 60 | /** 61 | * @} 62 | */ 63 | 64 | /** @defgroup RNG_interrupts_definition 65 | * @{ 66 | */ 67 | #define RNG_IT_CEI ((uint8_t)0x20) /*!< Clock error interrupt */ 68 | #define RNG_IT_SEI ((uint8_t)0x40) /*!< Seed error interrupt */ 69 | 70 | #define IS_RNG_IT(IT) ((((IT) & (uint8_t)0x9F) == 0x00) && ((IT) != 0x00)) 71 | #define IS_RNG_GET_IT(RNG_IT) (((RNG_IT) == RNG_IT_CEI) || ((RNG_IT) == RNG_IT_SEI)) 72 | /** 73 | * @} 74 | */ 75 | 76 | /** 77 | * @} 78 | */ 79 | 80 | /* Exported macro ------------------------------------------------------------*/ 81 | /* Exported functions --------------------------------------------------------*/ 82 | 83 | /* Function used to set the RNG configuration to the default reset state *****/ 84 | void RNG_DeInit(void); 85 | 86 | /* Configuration function *****************************************************/ 87 | void RNG_Cmd(FunctionalState NewState); 88 | 89 | /* Get 32 bit Random number function ******************************************/ 90 | uint32_t RNG_GetRandomNumber(void); 91 | 92 | /* Interrupts and flags management functions **********************************/ 93 | void RNG_ITConfig(FunctionalState NewState); 94 | FlagStatus RNG_GetFlagStatus(uint8_t RNG_FLAG); 95 | void RNG_ClearFlag(uint8_t RNG_FLAG); 96 | ITStatus RNG_GetITStatus(uint8_t RNG_IT); 97 | void RNG_ClearITPendingBit(uint8_t RNG_IT); 98 | #endif /* STM32F40_41xxx || STM32F427_437xx || STM32F410xx || STM32F412xG || STM32F413_423xx || STM32F429_439xx || STM32F469_479xx */ 99 | 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | 104 | #endif /*__STM32F4xx_RNG_H */ 105 | 106 | /** 107 | * @} 108 | */ 109 | 110 | /** 111 | * @} 112 | */ 113 | 114 | -------------------------------------------------------------------------------- /firmware/driver/inc/stm32f4xx_iwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_iwdg.h 4 | * @author MCD Application Team 5 | * @version V1.8.1 6 | * @date 27-January-2022 7 | * @brief This file contains all the functions prototypes for the IWDG 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * Copyright (c) 2016 STMicroelectronics. 13 | * All rights reserved. 14 | * 15 | * This software is licensed under terms that can be found in the LICENSE file 16 | * in the root directory of this software component. 17 | * If no LICENSE file comes with this software, it is provided AS-IS. 18 | * 19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F4xx_IWDG_H 24 | #define __STM32F4xx_IWDG_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f4xx.h" 32 | 33 | /** @addtogroup STM32F4xx_StdPeriph_Driver 34 | * @{ 35 | */ 36 | 37 | /** @addtogroup IWDG 38 | * @{ 39 | */ 40 | 41 | /* Exported types ------------------------------------------------------------*/ 42 | /* Exported constants --------------------------------------------------------*/ 43 | 44 | /** @defgroup IWDG_Exported_Constants 45 | * @{ 46 | */ 47 | 48 | /** @defgroup IWDG_WriteAccess 49 | * @{ 50 | */ 51 | #define IWDG_WriteAccess_Enable ((uint16_t)0x5555) 52 | #define IWDG_WriteAccess_Disable ((uint16_t)0x0000) 53 | #define IS_IWDG_WRITE_ACCESS(ACCESS) (((ACCESS) == IWDG_WriteAccess_Enable) || \ 54 | ((ACCESS) == IWDG_WriteAccess_Disable)) 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @defgroup IWDG_prescaler 60 | * @{ 61 | */ 62 | #define IWDG_Prescaler_4 ((uint8_t)0x00) 63 | #define IWDG_Prescaler_8 ((uint8_t)0x01) 64 | #define IWDG_Prescaler_16 ((uint8_t)0x02) 65 | #define IWDG_Prescaler_32 ((uint8_t)0x03) 66 | #define IWDG_Prescaler_64 ((uint8_t)0x04) 67 | #define IWDG_Prescaler_128 ((uint8_t)0x05) 68 | #define IWDG_Prescaler_256 ((uint8_t)0x06) 69 | #define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_Prescaler_4) || \ 70 | ((PRESCALER) == IWDG_Prescaler_8) || \ 71 | ((PRESCALER) == IWDG_Prescaler_16) || \ 72 | ((PRESCALER) == IWDG_Prescaler_32) || \ 73 | ((PRESCALER) == IWDG_Prescaler_64) || \ 74 | ((PRESCALER) == IWDG_Prescaler_128)|| \ 75 | ((PRESCALER) == IWDG_Prescaler_256)) 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup IWDG_Flag 81 | * @{ 82 | */ 83 | #define IWDG_FLAG_PVU ((uint16_t)0x0001) 84 | #define IWDG_FLAG_RVU ((uint16_t)0x0002) 85 | #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || ((FLAG) == IWDG_FLAG_RVU)) 86 | #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF) 87 | /** 88 | * @} 89 | */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /* Exported macro ------------------------------------------------------------*/ 96 | /* Exported functions --------------------------------------------------------*/ 97 | 98 | /* Prescaler and Counter configuration functions ******************************/ 99 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess); 100 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler); 101 | void IWDG_SetReload(uint16_t Reload); 102 | void IWDG_ReloadCounter(void); 103 | 104 | /* IWDG activation function ***************************************************/ 105 | void IWDG_Enable(void); 106 | 107 | /* Flag management function ***************************************************/ 108 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG); 109 | 110 | #ifdef __cplusplus 111 | } 112 | #endif 113 | 114 | #endif /* __STM32F4xx_IWDG_H */ 115 | 116 | /** 117 | * @} 118 | */ 119 | 120 | /** 121 | * @} 122 | */ 123 | 124 | -------------------------------------------------------------------------------- /firmware/cmsis/device/stm32f4xx_it.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/STM32F4xx_StdPeriph_Templates/stm32f4xx_it.c 4 | * @author MCD Application Team 5 | * @version V1.8.1 6 | * @date 27-January-2022 7 | * @brief Main Interrupt Service Routines. 8 | * This file provides template for all exceptions handler and 9 | * peripherals interrupt service routine. 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * Copyright (c) 2016 STMicroelectronics. 14 | * All rights reserved. 15 | * 16 | * This software is licensed under terms that can be found in the LICENSE file 17 | * in the root directory of this software component. 18 | * If no LICENSE file comes with this software, it is provided AS-IS. 19 | * 20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes ------------------------------------------------------------------*/ 24 | #include "stm32f4xx_it.h" 25 | #include "main.h" 26 | 27 | /** @addtogroup Template_Project 28 | * @{ 29 | */ 30 | 31 | /* Private typedef -----------------------------------------------------------*/ 32 | /* Private define ------------------------------------------------------------*/ 33 | /* Private macro -------------------------------------------------------------*/ 34 | /* Private variables ---------------------------------------------------------*/ 35 | /* Private function prototypes -----------------------------------------------*/ 36 | /* Private functions ---------------------------------------------------------*/ 37 | 38 | /******************************************************************************/ 39 | /* Cortex-M4 Processor Exceptions Handlers */ 40 | /******************************************************************************/ 41 | 42 | /** 43 | * @brief This function handles NMI exception. 44 | * @param None 45 | * @retval None 46 | */ 47 | void NMI_Handler(void) 48 | { 49 | } 50 | 51 | /** 52 | * @brief This function handles Hard Fault exception. 53 | * @param None 54 | * @retval None 55 | */ 56 | void HardFault_Handler(void) 57 | { 58 | /* Go to infinite loop when Hard Fault exception occurs */ 59 | while (1) 60 | { 61 | } 62 | } 63 | 64 | /** 65 | * @brief This function handles Memory Manage exception. 66 | * @param None 67 | * @retval None 68 | */ 69 | void MemManage_Handler(void) 70 | { 71 | /* Go to infinite loop when Memory Manage exception occurs */ 72 | while (1) 73 | { 74 | } 75 | } 76 | 77 | /** 78 | * @brief This function handles Bus Fault exception. 79 | * @param None 80 | * @retval None 81 | */ 82 | void BusFault_Handler(void) 83 | { 84 | /* Go to infinite loop when Bus Fault exception occurs */ 85 | while (1) 86 | { 87 | } 88 | } 89 | 90 | /** 91 | * @brief This function handles Usage Fault exception. 92 | * @param None 93 | * @retval None 94 | */ 95 | void UsageFault_Handler(void) 96 | { 97 | /* Go to infinite loop when Usage Fault exception occurs */ 98 | while (1) 99 | { 100 | } 101 | } 102 | 103 | /** 104 | * @brief This function handles SVCall exception. 105 | * @param None 106 | * @retval None 107 | */ 108 | void SVC_Handler(void) 109 | { 110 | } 111 | 112 | /** 113 | * @brief This function handles Debug Monitor exception. 114 | * @param None 115 | * @retval None 116 | */ 117 | void DebugMon_Handler(void) 118 | { 119 | } 120 | 121 | /** 122 | * @brief This function handles PendSVC exception. 123 | * @param None 124 | * @retval None 125 | */ 126 | void PendSV_Handler(void) 127 | { 128 | } 129 | 130 | /** 131 | * @brief This function handles SysTick Handler. 132 | * @param None 133 | * @retval None 134 | */ 135 | void SysTick_Handler(void) 136 | { 137 | TimingDelay_Decrement(); 138 | } 139 | 140 | /******************************************************************************/ 141 | /* STM32F4xx Peripherals Interrupt Handlers */ 142 | /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ 143 | /* available peripheral interrupt handler's name please refer to the startup */ 144 | /* file (startup_stm32f4xx.s). */ 145 | /******************************************************************************/ 146 | 147 | /** 148 | * @brief This function handles PPP interrupt request. 149 | * @param None 150 | * @retval None 151 | */ 152 | /*void PPP_IRQHandler(void) 153 | { 154 | }*/ 155 | 156 | /** 157 | * @} 158 | */ 159 | 160 | 161 | -------------------------------------------------------------------------------- /driver/console/console.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "FreeRTOS.h" 4 | #include "semphr.h" 5 | #include "stm32f4xx.h" 6 | #include "console.h" 7 | 8 | static SemaphoreHandle_t write_async_semaphore; 9 | static console_received_func_t received_func; 10 | 11 | static void console_io_init(void) 12 | { 13 | GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1); 14 | GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1); 15 | 16 | GPIO_InitTypeDef GPIO_InitStructure; 17 | GPIO_StructInit(&GPIO_InitStructure); 18 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; 19 | GPIO_InitStructure.GPIO_Speed = GPIO_High_Speed; 20 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10; 21 | GPIO_Init(GPIOA, &GPIO_InitStructure); 22 | } 23 | 24 | static void console_usart_init(void) 25 | { 26 | USART_InitTypeDef USART_InitStructure; 27 | USART_StructInit(&USART_InitStructure); 28 | 29 | USART_InitStructure.USART_BaudRate = 115200u; 30 | USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; 31 | USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; 32 | USART_InitStructure.USART_Parity = USART_Parity_No; 33 | USART_InitStructure.USART_StopBits = USART_StopBits_1; 34 | USART_InitStructure.USART_WordLength = USART_WordLength_8b; 35 | 36 | USART_Init(USART1, &USART_InitStructure); 37 | USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); 38 | USART_DMACmd(USART1, USART_DMAReq_Tx, ENABLE); 39 | USART_Cmd(USART1, ENABLE); 40 | } 41 | 42 | static void console_dma_init(void) 43 | { 44 | DMA_InitTypeDef DMA_InitStruct; 45 | DMA_StructInit(&DMA_InitStruct); 46 | DMA_InitStruct.DMA_Channel = DMA_Channel_4; 47 | DMA_InitStruct.DMA_PeripheralBaseAddr = (uint32_t)&USART1->DR; 48 | DMA_InitStruct.DMA_DIR = DMA_DIR_MemoryToPeripheral; 49 | DMA_InitStruct.DMA_PeripheralInc = DMA_PeripheralInc_Disable; 50 | DMA_InitStruct.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; 51 | DMA_InitStruct.DMA_MemoryInc = DMA_MemoryInc_Enable; 52 | DMA_InitStruct.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; 53 | DMA_InitStruct.DMA_Mode = DMA_Mode_Normal; 54 | DMA_InitStruct.DMA_Priority = DMA_Priority_Low; 55 | DMA_InitStruct.DMA_FIFOMode = DMA_FIFOMode_Enable; 56 | DMA_InitStruct.DMA_FIFOThreshold = DMA_FIFOThreshold_Full; 57 | DMA_InitStruct.DMA_MemoryBurst = DMA_MemoryBurst_INC8; 58 | DMA_InitStruct.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; 59 | DMA_ITConfig(DMA2_Stream7, DMA_IT_TC, ENABLE); 60 | DMA_Init(DMA2_Stream7, &DMA_InitStruct); 61 | } 62 | 63 | static void console_int_init(void) 64 | { 65 | NVIC_InitTypeDef NVIC_InitStructure; 66 | NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; 67 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 5; 68 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; 69 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 70 | NVIC_Init(&NVIC_InitStructure); 71 | NVIC_SetPriority(USART1_IRQn, 5); 72 | 73 | NVIC_InitStructure.NVIC_IRQChannel = DMA2_Stream7_IRQn; 74 | NVIC_Init(&NVIC_InitStructure); 75 | NVIC_SetPriority(DMA2_Stream7_IRQn, 5); 76 | } 77 | 78 | void console_init(void) 79 | { 80 | write_async_semaphore = xSemaphoreCreateBinary(); 81 | configASSERT(write_async_semaphore); 82 | 83 | console_usart_init(); 84 | console_dma_init(); 85 | console_int_init(); 86 | console_io_init(); 87 | } 88 | 89 | void console_write(const char str[]) 90 | { 91 | uint32_t len = strlen(str); 92 | do 93 | { 94 | uint32_t chunk_size = len < 65535 ? len : 65535; 95 | 96 | DMA2_Stream7->M0AR = (uint32_t)str; 97 | DMA2_Stream7->NDTR = chunk_size; 98 | 99 | DMA_Cmd(DMA2_Stream7, ENABLE); 100 | xSemaphoreTake(write_async_semaphore, portMAX_DELAY); 101 | 102 | str += chunk_size; 103 | len -= chunk_size; 104 | } while (len > 0); 105 | 106 | while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET); 107 | USART_ClearFlag(USART1, USART_FLAG_TC); 108 | } 109 | 110 | void console_received_register(console_received_func_t func) 111 | { 112 | received_func = func; 113 | } 114 | 115 | void USART1_IRQHandler(void) 116 | { 117 | if (USART_GetITStatus(USART1, USART_IT_RXNE) == SET) 118 | { 119 | if (received_func != NULL) 120 | { 121 | uint8_t data = USART_ReceiveData(USART1); 122 | received_func(data); 123 | } 124 | 125 | USART_ClearITPendingBit(USART1, USART_IT_RXNE); 126 | } 127 | } 128 | 129 | void DMA2_Stream7_IRQHandler(void) 130 | { 131 | if (DMA_GetITStatus(DMA2_Stream7, DMA_IT_TCIF7) == SET) 132 | { 133 | BaseType_t pxHigherPriorityTaskWoken; 134 | xSemaphoreGiveFromISR(write_async_semaphore, &pxHigherPriorityTaskWoken); 135 | portYIELD_FROM_ISR(pxHigherPriorityTaskWoken); 136 | 137 | DMA_ClearITPendingBit(DMA2_Stream7, DMA_IT_TCIF7); 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /driver/aht20/aht20.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "FreeRTOS.h" 4 | #include "task.h" 5 | #include "stm32f4xx.h" 6 | #include "tim_delay.h" 7 | 8 | static bool aht20_write(uint8_t data[], uint32_t length); 9 | static bool aht20_read(uint8_t data[], uint32_t length); 10 | static bool aht20_is_ready(void); 11 | 12 | bool aht20_init(void) 13 | { 14 | I2C_InitTypeDef I2C_InitStruct; 15 | I2C_StructInit(&I2C_InitStruct); 16 | I2C_InitStruct.I2C_Ack = I2C_Ack_Enable; 17 | I2C_InitStruct.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; 18 | I2C_InitStruct.I2C_ClockSpeed = 100ul * 1000ul; 19 | I2C_InitStruct.I2C_DutyCycle = I2C_DutyCycle_2; 20 | I2C_InitStruct.I2C_Mode = I2C_Mode_I2C; 21 | I2C_InitStruct.I2C_OwnAddress1 = 0x00; 22 | I2C_Init(I2C2, &I2C_InitStruct); 23 | 24 | GPIO_InitTypeDef GPIO_InitStruct; 25 | GPIO_StructInit(&GPIO_InitStruct); 26 | GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF; 27 | GPIO_InitStruct.GPIO_OType = GPIO_OType_OD; 28 | GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL; 29 | GPIO_InitStruct.GPIO_Speed = GPIO_High_Speed; 30 | GPIO_InitStruct.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11; 31 | GPIO_Init(GPIOB, &GPIO_InitStruct); 32 | GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_I2C2); 33 | GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_I2C2); 34 | 35 | vTaskDelay(pdMS_TO_TICKS(40)); 36 | if (aht20_is_ready()) 37 | return true; 38 | 39 | if (!aht20_write((uint8_t[]){0xBE, 0x08, 0x00}, 3)) 40 | return false; 41 | 42 | for (uint32_t t = 0; t < 20; t ++) 43 | { 44 | vTaskDelay(pdMS_TO_TICKS(5)); 45 | if (aht20_is_ready()) 46 | return true; 47 | } 48 | 49 | return false; 50 | } 51 | 52 | #define I2C_CHECK_EVENT(EVENT, TIMEOUT) \ 53 | do { \ 54 | uint32_t timeout = TIMEOUT; \ 55 | while (!I2C_CheckEvent(I2C2, EVENT) && timeout > 0) { \ 56 | tim_delay_us(10); \ 57 | timeout -= 10; \ 58 | } \ 59 | if (timeout <= 0) \ 60 | return false; \ 61 | } while (0) 62 | 63 | static bool aht20_write(uint8_t data[], uint32_t length) 64 | { 65 | I2C_AcknowledgeConfig(I2C2, ENABLE); 66 | I2C_GenerateSTART(I2C2, ENABLE); 67 | I2C_CHECK_EVENT(I2C_EVENT_MASTER_MODE_SELECT, 1000); 68 | I2C_Send7bitAddress(I2C2, 0x70, I2C_Direction_Transmitter); 69 | I2C_CHECK_EVENT(I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED, 1000); 70 | for (uint32_t i = 0; i < length; i++) 71 | { 72 | I2C_SendData(I2C2, data[i]); 73 | I2C_CHECK_EVENT(I2C_EVENT_MASTER_BYTE_TRANSMITTING, 1000); 74 | } 75 | I2C_GenerateSTOP(I2C2, ENABLE); 76 | 77 | return true; 78 | } 79 | 80 | static bool aht20_read(uint8_t data[], uint32_t length) 81 | { 82 | I2C_AcknowledgeConfig(I2C2, ENABLE); 83 | I2C_GenerateSTART(I2C2, ENABLE); 84 | I2C_CHECK_EVENT(I2C_EVENT_MASTER_MODE_SELECT, 1000); 85 | I2C_Send7bitAddress(I2C2, 0x70, I2C_Direction_Receiver); 86 | I2C_CHECK_EVENT(I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED, 1000); 87 | for (uint32_t i = 0; i < length; i++) 88 | { 89 | if (i == length - 1) 90 | I2C_AcknowledgeConfig(I2C2, DISABLE); 91 | I2C_CHECK_EVENT(I2C_EVENT_MASTER_BYTE_RECEIVED, 1000); 92 | data[i] = I2C_ReceiveData(I2C2); 93 | } 94 | I2C_GenerateSTOP(I2C2, ENABLE); 95 | 96 | return true; 97 | } 98 | 99 | static bool aht20_read_status(uint8_t *status) 100 | { 101 | uint8_t cmd = 0x71; 102 | if (!aht20_write(&cmd, 1)) 103 | return false; 104 | if (!aht20_read(status, 1)) 105 | return false; 106 | 107 | return true; 108 | } 109 | 110 | static bool aht20_is_busy(void) 111 | { 112 | uint8_t status; 113 | if (!aht20_read_status(&status)) 114 | return false; 115 | return (status & 0x80) != 0; 116 | } 117 | 118 | static bool aht20_is_ready(void) 119 | { 120 | uint8_t status; 121 | if (!aht20_read_status(&status)) 122 | return false; 123 | return (status & 0x08) != 0; 124 | } 125 | 126 | bool aht20_start_measurement(void) 127 | { 128 | return aht20_write((uint8_t[]){0xAC, 0x33, 0x00}, 3); 129 | } 130 | 131 | bool aht20_wait_for_measurement(void) 132 | { 133 | for (uint32_t t = 0; t < 20; t++) 134 | { 135 | vTaskDelay(pdMS_TO_TICKS(10)); 136 | if (!aht20_is_busy()) 137 | { 138 | return true; 139 | } 140 | } 141 | return false; 142 | } 143 | 144 | bool aht20_read_measurement(float *temperature, float *humidity) 145 | { 146 | uint8_t data[6]; 147 | if (!aht20_read(data, 6)) 148 | return false; 149 | 150 | uint32_t raw_humidity = ((uint32_t)data[1] << 12) | 151 | ((uint32_t)data[2] << 4) | 152 | ((uint32_t)(data[3] &0xF0) >> 4); 153 | uint32_t raw_temperature = ((uint32_t)(data[3] & 0x0F) << 16) | 154 | ((uint32_t)data[4] << 8) | 155 | ((uint32_t)data[5]); 156 | 157 | *humidity = (float)raw_humidity * 100.0f / (float)0x100000; 158 | *temperature = (float)raw_temperature * 200.0f / (float)0x100000 - 50.0f; 159 | 160 | return true; 161 | } 162 | -------------------------------------------------------------------------------- /third_lib/freertos/portable/FreeRTOSConfig.h: -------------------------------------------------------------------------------- 1 | #ifndef __FREERTOS_CONFIG_H__ 2 | #define __FREERTOS_CONFIG_H__ 3 | 4 | /* Here is a good place to include header files that are required across 5 | your application. */ 6 | #include "stm32f4xx.h" 7 | extern uint32_t SystemCoreClock; 8 | 9 | #define configUSE_PREEMPTION 1 10 | #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 11 | #define configUSE_TICKLESS_IDLE 0 12 | #define configCPU_CLOCK_HZ SystemCoreClock 13 | #define configTICK_RATE_HZ 1000 14 | #define configMAX_PRIORITIES 10 15 | #define configMINIMAL_STACK_SIZE 128 16 | #define configMAX_TASK_NAME_LEN 16 17 | #define configUSE_16_BIT_TICKS 0 18 | #define configIDLE_SHOULD_YIELD 1 19 | #define configUSE_TASK_NOTIFICATIONS 1 20 | #define configTASK_NOTIFICATION_ARRAY_ENTRIES 3 21 | #define configUSE_MUTEXES 1 22 | #define configUSE_RECURSIVE_MUTEXES 1 23 | #define configUSE_COUNTING_SEMAPHORES 1 24 | #define configUSE_ALTERNATIVE_API 0 /* Deprecated! */ 25 | #define configQUEUE_REGISTRY_SIZE 10 26 | #define configUSE_QUEUE_SETS 1 27 | #define configUSE_TIME_SLICING 1 28 | #define configUSE_NEWLIB_REENTRANT 0 29 | #define configENABLE_BACKWARD_COMPATIBILITY 0 30 | #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5 31 | #define configUSE_MINI_LIST_ITEM 1 32 | #define configSTACK_DEPTH_TYPE uint32_t 33 | #define configMESSAGE_BUFFER_LENGTH_TYPE size_t 34 | 35 | /* Memory allocation related definitions. */ 36 | #define configSUPPORT_STATIC_ALLOCATION 0 37 | #define configSUPPORT_DYNAMIC_ALLOCATION 1 38 | #define configTOTAL_HEAP_SIZE (92 * 1024) 39 | #define configAPPLICATION_ALLOCATED_HEAP 0 40 | 41 | /* Hook function related definitions. */ 42 | #define configUSE_IDLE_HOOK 0 43 | #define configUSE_TICK_HOOK 0 44 | #define configCHECK_FOR_STACK_OVERFLOW 1 45 | #define configUSE_MALLOC_FAILED_HOOK 1 46 | #define configUSE_DAEMON_TASK_STARTUP_HOOK 0 47 | #define configUSE_SB_COMPLETED_CALLBACK 0 48 | 49 | /* Run time and task stats gathering related definitions. */ 50 | #define configGENERATE_RUN_TIME_STATS 0 51 | #define configUSE_TRACE_FACILITY 0 52 | #define configUSE_STATS_FORMATTING_FUNCTIONS 0 53 | 54 | /* Co-routine related definitions. */ 55 | #define configUSE_CO_ROUTINES 0 56 | #define configMAX_CO_ROUTINE_PRIORITIES 1 57 | 58 | /* Software timer related definitions. */ 59 | #define configUSE_TIMERS 1 60 | #define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1) 61 | #define configTIMER_QUEUE_LENGTH 32 62 | #define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE 63 | 64 | /* Interrupt nesting behaviour configuration. */ 65 | #define configPRIO_BITS 4 66 | #define configKERNEL_INTERRUPT_PRIORITY (15 << (8 - configPRIO_BITS)) 67 | #define configMAX_SYSCALL_INTERRUPT_PRIORITY (5 << (8 - configPRIO_BITS)) 68 | #define configMAX_API_CALL_INTERRUPT_PRIORITY configMAX_SYSCALL_INTERRUPT_PRIORITY 69 | 70 | /* Define to trap errors during development. */ 71 | void vAssertCalled(const char *file, int line); 72 | #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ ) 73 | 74 | /* Optional functions - most linkers will remove unused functions anyway. */ 75 | #define INCLUDE_vTaskPrioritySet 1 76 | #define INCLUDE_uxTaskPriorityGet 1 77 | #define INCLUDE_vTaskDelete 1 78 | #define INCLUDE_vTaskSuspend 1 79 | #define INCLUDE_vTaskDelayUntil 1 80 | #define INCLUDE_vTaskDelay 1 81 | #define INCLUDE_xTaskGetSchedulerState 1 82 | #define INCLUDE_xTaskGetCurrentTaskHandle 1 83 | #define INCLUDE_uxTaskGetStackHighWaterMark 1 84 | #define INCLUDE_uxTaskGetStackHighWaterMark2 1 85 | #define INCLUDE_xTaskGetIdleTaskHandle 1 86 | #define INCLUDE_eTaskGetState 1 87 | #define INCLUDE_xTimerPendFunctionCall 0 88 | #define INCLUDE_xTaskAbortDelay 0 89 | #define INCLUDE_xTaskGetHandle 1 90 | #define INCLUDE_xTaskResumeFromISR 1 91 | 92 | /* A header file that defines trace macro can be included here. */ 93 | 94 | #define xPortPendSVHandler PendSV_Handler 95 | #define xPortSysTickHandler SysTick_Handler 96 | #define vPortSVCHandler SVC_Handler 97 | 98 | #endif /* FREERTOS_CONFIG_H */ 99 | 100 | -------------------------------------------------------------------------------- /firmware/driver/src/stm32f4xx_flash_ramfunc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_flash_ramfunc.c 4 | * @author MCD Application Team 5 | * @version V1.8.1 6 | * @date 27-January-2022 7 | * @brief FLASH RAMFUNC module driver. 8 | * This file provides a FLASH firmware functions which should be 9 | * executed from internal SRAM 10 | * + Stop/Start the flash interface while System Run 11 | * + Enable/Disable the flash sleep while System Run 12 | * 13 | @verbatim 14 | ============================================================================== 15 | ##### APIs executed from Internal RAM ##### 16 | ============================================================================== 17 | [..] 18 | *** ARM Compiler *** 19 | -------------------- 20 | [..] RAM functions are defined using the toolchain options. 21 | Functions that are be executed in RAM should reside in a separate 22 | source module. Using the 'Options for File' dialog you can simply change 23 | the 'Code / Const' area of a module to a memory space in physical RAM. 24 | Available memory areas are declared in the 'Target' tab of the 25 | Options for Target' dialog. 26 | 27 | *** ICCARM Compiler *** 28 | ----------------------- 29 | [..] RAM functions are defined using a specific toolchain keyword "__ramfunc". 30 | 31 | *** GNU Compiler *** 32 | -------------------- 33 | [..] RAM functions are defined using a specific toolchain attribute 34 | "__attribute__((section(".RamFunc")))". 35 | 36 | @endverbatim 37 | ****************************************************************************** 38 | * @attention 39 | * 40 | * Copyright (c) 2016 STMicroelectronics. 41 | * All rights reserved. 42 | * 43 | * This software is licensed under terms that can be found in the LICENSE file 44 | * in the root directory of this software component. 45 | * If no LICENSE file comes with this software, it is provided AS-IS. 46 | * 47 | ****************************************************************************** 48 | */ 49 | 50 | /* Includes ------------------------------------------------------------------*/ 51 | #include "stm32f4xx_flash_ramfunc.h" 52 | 53 | /** @addtogroup STM32F4xx_StdPeriph_Driver 54 | * @{ 55 | */ 56 | 57 | /** @defgroup FLASH RAMFUNC 58 | * @brief FLASH RAMFUNC driver modules 59 | * @{ 60 | */ 61 | 62 | /* Private typedef -----------------------------------------------------------*/ 63 | /* Private define ------------------------------------------------------------*/ 64 | /* Private macro -------------------------------------------------------------*/ 65 | /* Private variables ---------------------------------------------------------*/ 66 | /* Private function prototypes -----------------------------------------------*/ 67 | /* Private functions ---------------------------------------------------------*/ 68 | 69 | /** @defgroup FLASH_RAMFUNC_Private_Functions 70 | * @{ 71 | */ 72 | 73 | /** @defgroup FLASH_RAMFUNC_Group1 Peripheral features functions executed from internal RAM 74 | * @brief Peripheral Extended features functions 75 | * 76 | @verbatim 77 | 78 | =============================================================================== 79 | ##### ramfunc functions ##### 80 | =============================================================================== 81 | [..] 82 | This subsection provides a set of functions that should be executed from RAM 83 | transfers. 84 | 85 | @endverbatim 86 | * @{ 87 | */ 88 | 89 | /** 90 | * @brief Start/Stop the flash interface while System Run 91 | * @note This mode is only available for STM32F411xx devices. 92 | * @note This mode could n't be set while executing with the flash itself. 93 | * It should be done with specific routine executed from RAM. 94 | * @param NewState: new state of the Smart Card mode. 95 | * This parameter can be: ENABLE or DISABLE. 96 | * @retval None 97 | */ 98 | __RAM_FUNC FLASH_FlashInterfaceCmd(FunctionalState NewState) 99 | { 100 | if (NewState != DISABLE) 101 | { 102 | /* Start the flash interface while System Run */ 103 | CLEAR_BIT(PWR->CR, PWR_CR_FISSR); 104 | } 105 | else 106 | { 107 | /* Stop the flash interface while System Run */ 108 | SET_BIT(PWR->CR, PWR_CR_FISSR); 109 | } 110 | } 111 | 112 | /** 113 | * @brief Enable/Disable the flash sleep while System Run 114 | * @note This mode is only available for STM32F411xx devices. 115 | * @note This mode could n't be set while executing with the flash itself. 116 | * It should be done with specific routine executed from RAM. 117 | * @param NewState: new state of the Smart Card mode. 118 | * This parameter can be: ENABLE or DISABLE. 119 | * @retval None 120 | */ 121 | __RAM_FUNC FLASH_FlashSleepModeCmd(FunctionalState NewState) 122 | { 123 | if (NewState != DISABLE) 124 | { 125 | /* Enable the flash sleep while System Run */ 126 | SET_BIT(PWR->CR, PWR_CR_FMSSR); 127 | } 128 | else 129 | { 130 | /* Disable the flash sleep while System Run */ 131 | CLEAR_BIT(PWR->CR, PWR_CR_FMSSR); 132 | } 133 | } 134 | 135 | /** 136 | * @} 137 | */ 138 | 139 | /** 140 | * @} 141 | */ 142 | 143 | /** 144 | * @} 145 | */ 146 | 147 | /** 148 | * @} 149 | */ 150 | 151 | -------------------------------------------------------------------------------- /firmware/cmsis/device/stm32f4xx_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/STM32F4xx_StdPeriph_Templates/stm32f4xx_conf.h 4 | * @author MCD Application Team 5 | * @version V1.8.1 6 | * @date 27-January-2022 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * Copyright (c) 2016 STMicroelectronics. 12 | * All rights reserved. 13 | * 14 | * This software is licensed under terms that can be found in the LICENSE file 15 | * in the root directory of this software component. 16 | * If no LICENSE file comes with this software, it is provided AS-IS. 17 | * 18 | ****************************************************************************** 19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F4xx_CONF_H 23 | #define __STM32F4xx_CONF_H 24 | 25 | /* Includes ------------------------------------------------------------------*/ 26 | /* Uncomment the line below to enable peripheral header file inclusion */ 27 | #include "stm32f4xx_adc.h" 28 | #include "stm32f4xx_crc.h" 29 | #include "stm32f4xx_dbgmcu.h" 30 | #include "stm32f4xx_dma.h" 31 | #include "stm32f4xx_exti.h" 32 | #include "stm32f4xx_flash.h" 33 | #include "stm32f4xx_gpio.h" 34 | #include "stm32f4xx_i2c.h" 35 | #include "stm32f4xx_iwdg.h" 36 | #include "stm32f4xx_pwr.h" 37 | #include "stm32f4xx_rcc.h" 38 | #include "stm32f4xx_rtc.h" 39 | #include "stm32f4xx_sdio.h" 40 | #include "stm32f4xx_spi.h" 41 | #include "stm32f4xx_syscfg.h" 42 | #include "stm32f4xx_tim.h" 43 | #include "stm32f4xx_usart.h" 44 | #include "stm32f4xx_wwdg.h" 45 | #include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 46 | 47 | #if defined(STM32F429_439xx) || defined(STM32F446xx) || defined(STM32F469_479xx) 48 | #include "stm32f4xx_cryp.h" 49 | #include "stm32f4xx_hash.h" 50 | #include "stm32f4xx_rng.h" 51 | #include "stm32f4xx_can.h" 52 | #include "stm32f4xx_dac.h" 53 | #include "stm32f4xx_dcmi.h" 54 | #include "stm32f4xx_dma2d.h" 55 | #include "stm32f4xx_fmc.h" 56 | #include "stm32f4xx_ltdc.h" 57 | #include "stm32f4xx_sai.h" 58 | #endif /* STM32F429_439xx || STM32F446xx || STM32F469_479xx */ 59 | 60 | #if defined(STM32F427_437xx) 61 | #include "stm32f4xx_cryp.h" 62 | #include "stm32f4xx_hash.h" 63 | #include "stm32f4xx_rng.h" 64 | #include "stm32f4xx_can.h" 65 | #include "stm32f4xx_dac.h" 66 | #include "stm32f4xx_dcmi.h" 67 | #include "stm32f4xx_dma2d.h" 68 | #include "stm32f4xx_fmc.h" 69 | #include "stm32f4xx_sai.h" 70 | #endif /* STM32F427_437xx */ 71 | 72 | #if defined(STM32F40_41xxx) 73 | #include "stm32f4xx_cryp.h" 74 | #include "stm32f4xx_hash.h" 75 | #include "stm32f4xx_rng.h" 76 | #include "stm32f4xx_can.h" 77 | #include "stm32f4xx_dac.h" 78 | #include "stm32f4xx_dcmi.h" 79 | #include "stm32f4xx_fsmc.h" 80 | #endif /* STM32F40_41xxx */ 81 | 82 | #if defined(STM32F410xx) 83 | #include "stm32f4xx_rng.h" 84 | #include "stm32f4xx_dac.h" 85 | #endif /* STM32F410xx */ 86 | 87 | #if defined(STM32F411xE) 88 | #include "stm32f4xx_flash_ramfunc.h" 89 | #endif /* STM32F411xE */ 90 | 91 | #if defined(STM32F446xx) || defined(STM32F469_479xx) 92 | #include "stm32f4xx_qspi.h" 93 | #endif /* STM32F446xx || STM32F469_479xx */ 94 | 95 | #if defined(STM32F410xx) || defined(STM32F446xx) 96 | #include "stm32f4xx_fmpi2c.h" 97 | #endif /* STM32F410xx || STM32F446xx */ 98 | 99 | #if defined(STM32F446xx) 100 | #include "stm32f4xx_spdifrx.h" 101 | #include "stm32f4xx_cec.h" 102 | #endif /* STM32F446xx */ 103 | 104 | #if defined(STM32F469_479xx) 105 | #include "stm32f4xx_dsi.h" 106 | #endif /* STM32F469_479xx */ 107 | 108 | #if defined(STM32F410xx) 109 | #include "stm32f4xx_lptim.h" 110 | #endif /* STM32F410xx */ 111 | 112 | #if defined(STM32F412xG) 113 | #include "stm32f4xx_rng.h" 114 | #include "stm32f4xx_can.h" 115 | #include "stm32f4xx_qspi.h" 116 | #include "stm32f4xx_rng.h" 117 | #include "stm32f4xx_fsmc.h" 118 | #include "stm32f4xx_dfsdm.h" 119 | #endif /* STM32F412xG */ 120 | 121 | #if defined(STM32F413_423xx) 122 | #include "stm32f4xx_cryp.h" 123 | #include "stm32f4xx_fmpi2c.h" 124 | #include "stm32f4xx_rng.h" 125 | #include "stm32f4xx_can.h" 126 | #include "stm32f4xx_qspi.h" 127 | #include "stm32f4xx_rng.h" 128 | #include "stm32f4xx_fsmc.h" 129 | #include "stm32f4xx_dfsdm.h" 130 | #endif /* STM32F413_423xx */ 131 | 132 | /* Exported types ------------------------------------------------------------*/ 133 | /* Exported constants --------------------------------------------------------*/ 134 | 135 | /* If an external clock source is used, then the value of the following define 136 | should be set to the value of the external clock source, else, if no external 137 | clock is used, keep this define commented */ 138 | /*#define I2S_EXTERNAL_CLOCK_VAL 12288000 */ /* Value of the external clock in Hz */ 139 | 140 | 141 | /* Uncomment the line below to expanse the "assert_param" macro in the 142 | Standard Peripheral Library drivers code */ 143 | /* #define USE_FULL_ASSERT 1 */ 144 | 145 | /* Exported macro ------------------------------------------------------------*/ 146 | #ifdef USE_FULL_ASSERT 147 | 148 | /** 149 | * @brief The assert_param macro is used for function's parameters check. 150 | * @param expr: If expr is false, it calls assert_failed function 151 | * which reports the name of the source file and the source 152 | * line number of the call that failed. 153 | * If expr is true, it returns no value. 154 | * @retval None 155 | */ 156 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 157 | /* Exported functions ------------------------------------------------------- */ 158 | void assert_failed(uint8_t* file, uint32_t line); 159 | #else 160 | #define assert_param(expr) ((void)0) 161 | #endif /* USE_FULL_ASSERT */ 162 | 163 | #endif /* __STM32F4xx_CONF_H */ 164 | 165 | -------------------------------------------------------------------------------- /app/image/icon_wifi.c: -------------------------------------------------------------------------------- 1 | #include "image.h" 2 | 3 | static const unsigned char gImage_icon_wifi[1152] = { /* 0X00,0X10,0X18,0X00,0X18,0X00,0X01,0X1B, */ 4 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 5 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 6 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 7 | 0XFF,0XFF,0XDF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 8 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 9 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 10 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 11 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 12 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 13 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 14 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 15 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 16 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XBA,0XD6, 17 | 0XD3,0X9C,0X34,0XA5,0X55,0XAD,0X96,0XB5,0X96,0XB5,0X55,0XAD,0X34,0XA5,0XD3,0X9C, 18 | 0XBA,0XD6,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 19 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X38,0XC6,0XB6,0XB5,0X34,0XA5, 20 | 0X71,0X8C,0X55,0XAD,0X96,0XB5,0X75,0XAD,0X75,0XAD,0X96,0XB5,0X55,0XAD,0X71,0X8C, 21 | 0X55,0XAD,0XB6,0XB5,0X59,0XCE,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 22 | 0XFF,0XFF,0XFF,0XFF,0XDF,0XFF,0X9E,0XF7,0X96,0XB5,0XD3,0X9C,0X14,0XA5,0X55,0XAD, 23 | 0X96,0XB5,0XFB,0XDE,0XDF,0XFF,0XFF,0XFF,0XFF,0XFF,0XDF,0XFF,0XFB,0XDE,0X96,0XB5, 24 | 0X75,0XAD,0X14,0XA5,0XD3,0X9C,0XB6,0XB5,0X9E,0XF7,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 25 | 0XFF,0XFF,0XFF,0XFF,0X9A,0XD6,0X18,0XC6,0X51,0X8C,0XD7,0XBD,0X9A,0XD6,0XFF,0XFF, 26 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 27 | 0XFF,0XFF,0X79,0XCE,0XD7,0XBD,0X51,0X8C,0X18,0XC6,0X9A,0XD6,0XFF,0XFF,0XFF,0XFF, 28 | 0XFF,0XFF,0XFF,0XFF,0XFB,0XDE,0X55,0XAD,0X55,0XAD,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 29 | 0X79,0XCE,0XF3,0X9C,0X55,0XAD,0X75,0XAD,0X75,0XAD,0X55,0XAD,0XF3,0X9C,0X9A,0XD6, 30 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XB6,0XB5,0X14,0XA5,0X3C,0XE7,0XFF,0XFF,0XFF,0XFF, 31 | 0XFF,0XFF,0XDF,0XFF,0XBA,0XD6,0X38,0XC6,0XFF,0XFF,0XDF,0XFF,0X3C,0XE7,0XD7,0XBD, 32 | 0XF3,0X9C,0X92,0X94,0X96,0XB5,0X96,0XB5,0X75,0XAD,0X75,0XAD,0X92,0X94,0X14,0XA5, 33 | 0XB6,0XB5,0X3C,0XE7,0XDF,0XFF,0XDF,0XFF,0X9A,0XD6,0X79,0XCE,0XDF,0XFF,0XFF,0XFF, 34 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XDF,0XFF,0XFF,0XFF,0X79,0XCE,0XD7,0XBD,0X71,0X8C, 35 | 0X96,0XB5,0XF7,0XBD,0X9E,0XF7,0XFF,0XFF,0XFF,0XFF,0X9E,0XF7,0XF7,0XBD,0XB6,0XB5, 36 | 0X92,0X94,0XD7,0XBD,0XBA,0XD6,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 37 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X3C,0XE7,0X96,0XB5,0X96,0XB5, 38 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 39 | 0XF7,0XBD,0X34,0XA5,0X1C,0XE7,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 40 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X59,0XCE,0X79,0XCE,0XFF,0XFF, 41 | 0XFF,0XFF,0XD7,0XBD,0X55,0XAD,0X55,0XAD,0X55,0XAD,0X55,0XAD,0XD7,0XBD,0XFF,0XFF, 42 | 0XFF,0XFF,0X9A,0XD6,0X79,0XCE,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 43 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XDF,0XFF,0XFF,0XFF, 44 | 0XF7,0XBD,0XD3,0X9C,0XF3,0X9C,0XB6,0XB5,0X96,0XB5,0XD3,0X9C,0XD3,0X9C,0X18,0XC6, 45 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 46 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XDF,0XFF,0XFF,0XFF,0X55,0XAD, 47 | 0X92,0X94,0X96,0XB5,0XDB,0XDE,0XFF,0XFF,0XDF,0XFF,0XBA,0XD6,0X96,0XB5,0XB2,0X94, 48 | 0X75,0XAD,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 49 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XDF,0XFF,0XFF,0XFF, 50 | 0X55,0XAD,0XFF,0XFF,0XDF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X34,0XA5, 51 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 52 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 53 | 0XFF,0XFF,0XFF,0XFF,0XBE,0XF7,0X59,0XCE,0X59,0XCE,0XBE,0XF7,0XFF,0XFF,0XFF,0XFF, 54 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 55 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 56 | 0XFF,0XFF,0XFF,0XFF,0X34,0XA5,0X71,0X8C,0X71,0X8C,0X34,0XA5,0XFF,0XFF,0XFF,0XFF, 57 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 58 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 59 | 0XFF,0XFF,0XFF,0XFF,0XDF,0XFF,0X38,0XC6,0X38,0XC6,0XBE,0XF7,0XFF,0XFF,0XFF,0XFF, 60 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 61 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 62 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XDF,0XFF,0XFF,0XFF,0XFF,0XFF, 63 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 64 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 65 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 66 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 67 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 68 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XDF,0XFF,0XFF,0XFF,0XFF,0XFF, 69 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 70 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 71 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 72 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 73 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 74 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 75 | 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 76 | }; 77 | 78 | const image_t icon_wifi = 79 | { 80 | .width = 24, 81 | .height = 24, 82 | .data = gImage_icon_wifi, 83 | }; 84 | -------------------------------------------------------------------------------- /third_lib/freertos/include/projdefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.4.3 LTS Patch 3 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * https://www.FreeRTOS.org 23 | * https://github.com/FreeRTOS 24 | * 25 | */ 26 | 27 | #ifndef PROJDEFS_H 28 | #define PROJDEFS_H 29 | 30 | /* 31 | * Defines the prototype to which task functions must conform. Defined in this 32 | * file to ensure the type is known before portable.h is included. 33 | */ 34 | typedef void (* TaskFunction_t)( void * ); 35 | 36 | /* Converts a time in milliseconds to a time in ticks. This macro can be 37 | * overridden by a macro of the same name defined in FreeRTOSConfig.h in case the 38 | * definition here is not suitable for your application. */ 39 | #ifndef pdMS_TO_TICKS 40 | #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000U ) ) 41 | #endif 42 | 43 | #define pdFALSE ( ( BaseType_t ) 0 ) 44 | #define pdTRUE ( ( BaseType_t ) 1 ) 45 | 46 | #define pdPASS ( pdTRUE ) 47 | #define pdFAIL ( pdFALSE ) 48 | #define errQUEUE_EMPTY ( ( BaseType_t ) 0 ) 49 | #define errQUEUE_FULL ( ( BaseType_t ) 0 ) 50 | 51 | /* FreeRTOS error definitions. */ 52 | #define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 ) 53 | #define errQUEUE_BLOCKED ( -4 ) 54 | #define errQUEUE_YIELD ( -5 ) 55 | 56 | /* Macros used for basic data corruption checks. */ 57 | #ifndef configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 58 | #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0 59 | #endif 60 | 61 | #if ( configUSE_16_BIT_TICKS == 1 ) 62 | #define pdINTEGRITY_CHECK_VALUE 0x5a5a 63 | #else 64 | #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL 65 | #endif 66 | 67 | /* The following errno values are used by FreeRTOS+ components, not FreeRTOS 68 | * itself. */ 69 | #define pdFREERTOS_ERRNO_NONE 0 /* No errors */ 70 | #define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */ 71 | #define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */ 72 | #define pdFREERTOS_ERRNO_EIO 5 /* I/O error */ 73 | #define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */ 74 | #define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */ 75 | #define pdFREERTOS_ERRNO_EAGAIN 11 /* No more processes */ 76 | #define pdFREERTOS_ERRNO_EWOULDBLOCK 11 /* Operation would block */ 77 | #define pdFREERTOS_ERRNO_ENOMEM 12 /* Not enough memory */ 78 | #define pdFREERTOS_ERRNO_EACCES 13 /* Permission denied */ 79 | #define pdFREERTOS_ERRNO_EFAULT 14 /* Bad address */ 80 | #define pdFREERTOS_ERRNO_EBUSY 16 /* Mount device busy */ 81 | #define pdFREERTOS_ERRNO_EEXIST 17 /* File exists */ 82 | #define pdFREERTOS_ERRNO_EXDEV 18 /* Cross-device link */ 83 | #define pdFREERTOS_ERRNO_ENODEV 19 /* No such device */ 84 | #define pdFREERTOS_ERRNO_ENOTDIR 20 /* Not a directory */ 85 | #define pdFREERTOS_ERRNO_EISDIR 21 /* Is a directory */ 86 | #define pdFREERTOS_ERRNO_EINVAL 22 /* Invalid argument */ 87 | #define pdFREERTOS_ERRNO_ENOSPC 28 /* No space left on device */ 88 | #define pdFREERTOS_ERRNO_ESPIPE 29 /* Illegal seek */ 89 | #define pdFREERTOS_ERRNO_EROFS 30 /* Read only file system */ 90 | #define pdFREERTOS_ERRNO_EUNATCH 42 /* Protocol driver not attached */ 91 | #define pdFREERTOS_ERRNO_EBADE 50 /* Invalid exchange */ 92 | #define pdFREERTOS_ERRNO_EFTYPE 79 /* Inappropriate file type or format */ 93 | #define pdFREERTOS_ERRNO_ENMFILE 89 /* No more files */ 94 | #define pdFREERTOS_ERRNO_ENOTEMPTY 90 /* Directory not empty */ 95 | #define pdFREERTOS_ERRNO_ENAMETOOLONG 91 /* File or path name too long */ 96 | #define pdFREERTOS_ERRNO_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ 97 | #define pdFREERTOS_ERRNO_ENOBUFS 105 /* No buffer space available */ 98 | #define pdFREERTOS_ERRNO_ENOPROTOOPT 109 /* Protocol not available */ 99 | #define pdFREERTOS_ERRNO_EADDRINUSE 112 /* Address already in use */ 100 | #define pdFREERTOS_ERRNO_ETIMEDOUT 116 /* Connection timed out */ 101 | #define pdFREERTOS_ERRNO_EINPROGRESS 119 /* Connection already in progress */ 102 | #define pdFREERTOS_ERRNO_EALREADY 120 /* Socket already connected */ 103 | #define pdFREERTOS_ERRNO_EADDRNOTAVAIL 125 /* Address not available */ 104 | #define pdFREERTOS_ERRNO_EISCONN 127 /* Socket is already connected */ 105 | #define pdFREERTOS_ERRNO_ENOTCONN 128 /* Socket is not connected */ 106 | #define pdFREERTOS_ERRNO_ENOMEDIUM 135 /* No medium inserted */ 107 | #define pdFREERTOS_ERRNO_EILSEQ 138 /* An invalid UTF-16 sequence was encountered. */ 108 | #define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */ 109 | 110 | /* The following endian values are used by FreeRTOS+ components, not FreeRTOS 111 | * itself. */ 112 | #define pdFREERTOS_LITTLE_ENDIAN 0 113 | #define pdFREERTOS_BIG_ENDIAN 1 114 | 115 | /* Re-defining endian values for generic naming. */ 116 | #define pdLITTLE_ENDIAN pdFREERTOS_LITTLE_ENDIAN 117 | #define pdBIG_ENDIAN pdFREERTOS_BIG_ENDIAN 118 | 119 | 120 | #endif /* PROJDEFS_H */ 121 | -------------------------------------------------------------------------------- /firmware/driver/src/stm32f4xx_dbgmcu.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_dbgmcu.c 4 | * @author MCD Application Team 5 | * @version V1.8.1 6 | * @date 27-January-2022 7 | * @brief This file provides all the DBGMCU firmware functions. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * Copyright (c) 2016 STMicroelectronics. 12 | * All rights reserved. 13 | * 14 | * This software is licensed under terms that can be found in the LICENSE file 15 | * in the root directory of this software component. 16 | * If no LICENSE file comes with this software, it is provided AS-IS. 17 | * 18 | ****************************************************************************** 19 | */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "stm32f4xx_dbgmcu.h" 23 | 24 | /** @addtogroup STM32F4xx_StdPeriph_Driver 25 | * @{ 26 | */ 27 | 28 | /** @defgroup DBGMCU 29 | * @brief DBGMCU driver modules 30 | * @{ 31 | */ 32 | 33 | /* Private typedef -----------------------------------------------------------*/ 34 | /* Private define ------------------------------------------------------------*/ 35 | #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF) 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* Private variables ---------------------------------------------------------*/ 39 | /* Private function prototypes -----------------------------------------------*/ 40 | /* Private functions ---------------------------------------------------------*/ 41 | 42 | /** @defgroup DBGMCU_Private_Functions 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @brief Returns the device revision identifier. 48 | * @param None 49 | * @retval Device revision identifier 50 | */ 51 | uint32_t DBGMCU_GetREVID(void) 52 | { 53 | return(DBGMCU->IDCODE >> 16); 54 | } 55 | 56 | /** 57 | * @brief Returns the device identifier. 58 | * @param None 59 | * @retval Device identifier 60 | */ 61 | uint32_t DBGMCU_GetDEVID(void) 62 | { 63 | return(DBGMCU->IDCODE & IDCODE_DEVID_MASK); 64 | } 65 | 66 | /** 67 | * @brief Configures low power mode behavior when the MCU is in Debug mode. 68 | * @param DBGMCU_Periph: specifies the low power mode. 69 | * This parameter can be any combination of the following values: 70 | * @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode 71 | * @arg DBGMCU_STOP: Keep debugger connection during STOP mode 72 | * @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode 73 | * @param NewState: new state of the specified low power mode in Debug mode. 74 | * This parameter can be: ENABLE or DISABLE. 75 | * @retval None 76 | */ 77 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState) 78 | { 79 | /* Check the parameters */ 80 | assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph)); 81 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 82 | if (NewState != DISABLE) 83 | { 84 | DBGMCU->CR |= DBGMCU_Periph; 85 | } 86 | else 87 | { 88 | DBGMCU->CR &= ~DBGMCU_Periph; 89 | } 90 | } 91 | 92 | /** 93 | * @brief Configures APB1 peripheral behavior when the MCU is in Debug mode. 94 | * @param DBGMCU_Periph: specifies the APB1 peripheral. 95 | * This parameter can be any combination of the following values: 96 | * @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted 97 | * @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted 98 | * @arg DBGMCU_TIM4_STOP: TIM4 counter stopped when Core is halted 99 | * @arg DBGMCU_TIM5_STOP: TIM5 counter stopped when Core is halted 100 | * @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted 101 | * @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted 102 | * @arg DBGMCU_TIM12_STOP: TIM12 counter stopped when Core is halted 103 | * @arg DBGMCU_TIM13_STOP: TIM13 counter stopped when Core is halted 104 | * @arg DBGMCU_TIM14_STOP: TIM14 counter stopped when Core is halted 105 | * @arg DBGMCU_RTC_STOP: RTC Calendar and Wakeup counter stopped when Core is halted. 106 | * @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted 107 | * @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted 108 | * @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is halted 109 | * @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is halted 110 | * @arg DBGMCU_I2C3_SMBUS_TIMEOUT: I2C3 SMBUS timeout mode stopped when Core is halted 111 | * @arg DBGMCU_CAN2_STOP: Debug CAN1 stopped when Core is halted 112 | * @arg DBGMCU_CAN1_STOP: Debug CAN2 stopped when Core is halted 113 | * This parameter can be: ENABLE or DISABLE. 114 | * @retval None 115 | */ 116 | void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState) 117 | { 118 | /* Check the parameters */ 119 | assert_param(IS_DBGMCU_APB1PERIPH(DBGMCU_Periph)); 120 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 121 | 122 | if (NewState != DISABLE) 123 | { 124 | DBGMCU->APB1FZ |= DBGMCU_Periph; 125 | } 126 | else 127 | { 128 | DBGMCU->APB1FZ &= ~DBGMCU_Periph; 129 | } 130 | } 131 | 132 | /** 133 | * @brief Configures APB2 peripheral behavior when the MCU is in Debug mode. 134 | * @param DBGMCU_Periph: specifies the APB2 peripheral. 135 | * This parameter can be any combination of the following values: 136 | * @arg DBGMCU_TIM1_STOP: TIM1 counter stopped when Core is halted 137 | * @arg DBGMCU_TIM8_STOP: TIM8 counter stopped when Core is halted 138 | * @arg DBGMCU_TIM9_STOP: TIM9 counter stopped when Core is halted 139 | * @arg DBGMCU_TIM10_STOP: TIM10 counter stopped when Core is halted 140 | * @arg DBGMCU_TIM11_STOP: TIM11 counter stopped when Core is halted 141 | * @param NewState: new state of the specified peripheral in Debug mode. 142 | * This parameter can be: ENABLE or DISABLE. 143 | * @retval None 144 | */ 145 | void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState) 146 | { 147 | /* Check the parameters */ 148 | assert_param(IS_DBGMCU_APB2PERIPH(DBGMCU_Periph)); 149 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 150 | 151 | if (NewState != DISABLE) 152 | { 153 | DBGMCU->APB2FZ |= DBGMCU_Periph; 154 | } 155 | else 156 | { 157 | DBGMCU->APB2FZ &= ~DBGMCU_Periph; 158 | } 159 | } 160 | 161 | /** 162 | * @} 163 | */ 164 | 165 | /** 166 | * @} 167 | */ 168 | 169 | /** 170 | * @} 171 | */ 172 | 173 | -------------------------------------------------------------------------------- /firmware/driver/inc/misc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file misc.h 4 | * @author MCD Application Team 5 | * @version V1.8.1 6 | * @date 27-January-2022 7 | * @brief This file contains all the functions prototypes for the miscellaneous 8 | * firmware library functions (add-on to CMSIS functions). 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * Copyright (c) 2016 STMicroelectronics. 13 | * All rights reserved. 14 | * 15 | * This software is licensed under terms that can be found in the LICENSE file 16 | * in the root directory of this software component. 17 | * If no LICENSE file comes with this software, it is provided AS-IS. 18 | * 19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __MISC_H 24 | #define __MISC_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f4xx.h" 32 | 33 | /** @addtogroup STM32F4xx_StdPeriph_Driver 34 | * @{ 35 | */ 36 | 37 | /** @addtogroup MISC 38 | * @{ 39 | */ 40 | 41 | /* Exported types ------------------------------------------------------------*/ 42 | 43 | /** 44 | * @brief NVIC Init Structure definition 45 | */ 46 | 47 | typedef struct 48 | { 49 | uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled. 50 | This parameter can be an enumerator of @ref IRQn_Type 51 | enumeration (For the complete STM32 Devices IRQ Channels 52 | list, please refer to stm32f4xx.h file) */ 53 | 54 | uint8_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the IRQ channel 55 | specified in NVIC_IRQChannel. This parameter can be a value 56 | between 0 and 15 as described in the table @ref MISC_NVIC_Priority_Table 57 | A lower priority value indicates a higher priority */ 58 | 59 | uint8_t NVIC_IRQChannelSubPriority; /*!< Specifies the subpriority level for the IRQ channel specified 60 | in NVIC_IRQChannel. This parameter can be a value 61 | between 0 and 15 as described in the table @ref MISC_NVIC_Priority_Table 62 | A lower priority value indicates a higher priority */ 63 | 64 | FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel 65 | will be enabled or disabled. 66 | This parameter can be set either to ENABLE or DISABLE */ 67 | } NVIC_InitTypeDef; 68 | 69 | /* Exported constants --------------------------------------------------------*/ 70 | 71 | /** @defgroup MISC_Exported_Constants 72 | * @{ 73 | */ 74 | 75 | /** @defgroup MISC_Vector_Table_Base 76 | * @{ 77 | */ 78 | 79 | #define NVIC_VectTab_RAM ((uint32_t)0x20000000) 80 | #define NVIC_VectTab_FLASH ((uint32_t)0x08000000) 81 | #define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \ 82 | ((VECTTAB) == NVIC_VectTab_FLASH)) 83 | /** 84 | * @} 85 | */ 86 | 87 | /** @defgroup MISC_System_Low_Power 88 | * @{ 89 | */ 90 | 91 | #define NVIC_LP_SEVONPEND ((uint8_t)0x10) 92 | #define NVIC_LP_SLEEPDEEP ((uint8_t)0x04) 93 | #define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02) 94 | #define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \ 95 | ((LP) == NVIC_LP_SLEEPDEEP) || \ 96 | ((LP) == NVIC_LP_SLEEPONEXIT)) 97 | /** 98 | * @} 99 | */ 100 | 101 | /** @defgroup MISC_Preemption_Priority_Group 102 | * @{ 103 | */ 104 | 105 | #define NVIC_PriorityGroup_0 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority 106 | 4 bits for subpriority */ 107 | #define NVIC_PriorityGroup_1 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority 108 | 3 bits for subpriority */ 109 | #define NVIC_PriorityGroup_2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority 110 | 2 bits for subpriority */ 111 | #define NVIC_PriorityGroup_3 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority 112 | 1 bits for subpriority */ 113 | #define NVIC_PriorityGroup_4 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority 114 | 0 bits for subpriority */ 115 | 116 | #define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \ 117 | ((GROUP) == NVIC_PriorityGroup_1) || \ 118 | ((GROUP) == NVIC_PriorityGroup_2) || \ 119 | ((GROUP) == NVIC_PriorityGroup_3) || \ 120 | ((GROUP) == NVIC_PriorityGroup_4)) 121 | 122 | #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) 123 | 124 | #define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) 125 | 126 | #define IS_NVIC_OFFSET(OFFSET) ((OFFSET) < 0x000FFFFF) 127 | 128 | /** 129 | * @} 130 | */ 131 | 132 | /** @defgroup MISC_SysTick_clock_source 133 | * @{ 134 | */ 135 | 136 | #define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB) 137 | #define SysTick_CLKSource_HCLK ((uint32_t)0x00000004) 138 | #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \ 139 | ((SOURCE) == SysTick_CLKSource_HCLK_Div8)) 140 | /** 141 | * @} 142 | */ 143 | 144 | /** 145 | * @} 146 | */ 147 | 148 | /* Exported macro ------------------------------------------------------------*/ 149 | /* Exported functions --------------------------------------------------------*/ 150 | 151 | void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup); 152 | void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct); 153 | void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset); 154 | void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState); 155 | void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource); 156 | 157 | #ifdef __cplusplus 158 | } 159 | #endif 160 | 161 | #endif /* __MISC_H */ 162 | 163 | /** 164 | * @} 165 | */ 166 | 167 | /** 168 | * @} 169 | */ 170 | 171 | -------------------------------------------------------------------------------- /firmware/cmsis/core/arm_common_tables.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 19. March 2015 5 | * $Revision: V.1.4.5 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_common_tables.h 9 | * 10 | * Description: This file has extern declaration for common tables like Bitreverse, reciprocal etc which are used across different functions 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions 16 | * are met: 17 | * - Redistributions of source code must retain the above copyright 18 | * notice, this list of conditions and the following disclaimer. 19 | * - Redistributions in binary form must reproduce the above copyright 20 | * notice, this list of conditions and the following disclaimer in 21 | * the documentation and/or other materials provided with the 22 | * distribution. 23 | * - Neither the name of ARM LIMITED nor the names of its contributors 24 | * may be used to endorse or promote products derived from this 25 | * software without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 30 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 31 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 34 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * -------------------------------------------------------------------- */ 40 | 41 | #ifndef _ARM_COMMON_TABLES_H 42 | #define _ARM_COMMON_TABLES_H 43 | 44 | #include "arm_math.h" 45 | 46 | extern const uint16_t armBitRevTable[1024]; 47 | extern const q15_t armRecipTableQ15[64]; 48 | extern const q31_t armRecipTableQ31[64]; 49 | //extern const q31_t realCoefAQ31[1024]; 50 | //extern const q31_t realCoefBQ31[1024]; 51 | extern const float32_t twiddleCoef_16[32]; 52 | extern const float32_t twiddleCoef_32[64]; 53 | extern const float32_t twiddleCoef_64[128]; 54 | extern const float32_t twiddleCoef_128[256]; 55 | extern const float32_t twiddleCoef_256[512]; 56 | extern const float32_t twiddleCoef_512[1024]; 57 | extern const float32_t twiddleCoef_1024[2048]; 58 | extern const float32_t twiddleCoef_2048[4096]; 59 | extern const float32_t twiddleCoef_4096[8192]; 60 | #define twiddleCoef twiddleCoef_4096 61 | extern const q31_t twiddleCoef_16_q31[24]; 62 | extern const q31_t twiddleCoef_32_q31[48]; 63 | extern const q31_t twiddleCoef_64_q31[96]; 64 | extern const q31_t twiddleCoef_128_q31[192]; 65 | extern const q31_t twiddleCoef_256_q31[384]; 66 | extern const q31_t twiddleCoef_512_q31[768]; 67 | extern const q31_t twiddleCoef_1024_q31[1536]; 68 | extern const q31_t twiddleCoef_2048_q31[3072]; 69 | extern const q31_t twiddleCoef_4096_q31[6144]; 70 | extern const q15_t twiddleCoef_16_q15[24]; 71 | extern const q15_t twiddleCoef_32_q15[48]; 72 | extern const q15_t twiddleCoef_64_q15[96]; 73 | extern const q15_t twiddleCoef_128_q15[192]; 74 | extern const q15_t twiddleCoef_256_q15[384]; 75 | extern const q15_t twiddleCoef_512_q15[768]; 76 | extern const q15_t twiddleCoef_1024_q15[1536]; 77 | extern const q15_t twiddleCoef_2048_q15[3072]; 78 | extern const q15_t twiddleCoef_4096_q15[6144]; 79 | extern const float32_t twiddleCoef_rfft_32[32]; 80 | extern const float32_t twiddleCoef_rfft_64[64]; 81 | extern const float32_t twiddleCoef_rfft_128[128]; 82 | extern const float32_t twiddleCoef_rfft_256[256]; 83 | extern const float32_t twiddleCoef_rfft_512[512]; 84 | extern const float32_t twiddleCoef_rfft_1024[1024]; 85 | extern const float32_t twiddleCoef_rfft_2048[2048]; 86 | extern const float32_t twiddleCoef_rfft_4096[4096]; 87 | 88 | 89 | /* floating-point bit reversal tables */ 90 | #define ARMBITREVINDEXTABLE__16_TABLE_LENGTH ((uint16_t)20 ) 91 | #define ARMBITREVINDEXTABLE__32_TABLE_LENGTH ((uint16_t)48 ) 92 | #define ARMBITREVINDEXTABLE__64_TABLE_LENGTH ((uint16_t)56 ) 93 | #define ARMBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208 ) 94 | #define ARMBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440 ) 95 | #define ARMBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448 ) 96 | #define ARMBITREVINDEXTABLE1024_TABLE_LENGTH ((uint16_t)1800) 97 | #define ARMBITREVINDEXTABLE2048_TABLE_LENGTH ((uint16_t)3808) 98 | #define ARMBITREVINDEXTABLE4096_TABLE_LENGTH ((uint16_t)4032) 99 | 100 | extern const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE__16_TABLE_LENGTH]; 101 | extern const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE__32_TABLE_LENGTH]; 102 | extern const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE__64_TABLE_LENGTH]; 103 | extern const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH]; 104 | extern const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH]; 105 | extern const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH]; 106 | extern const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE1024_TABLE_LENGTH]; 107 | extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE2048_TABLE_LENGTH]; 108 | extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE4096_TABLE_LENGTH]; 109 | 110 | /* fixed-point bit reversal tables */ 111 | #define ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH ((uint16_t)12 ) 112 | #define ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH ((uint16_t)24 ) 113 | #define ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH ((uint16_t)56 ) 114 | #define ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH ((uint16_t)112 ) 115 | #define ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH ((uint16_t)240 ) 116 | #define ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH ((uint16_t)480 ) 117 | #define ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH ((uint16_t)992 ) 118 | #define ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH ((uint16_t)1984) 119 | #define ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH ((uint16_t)4032) 120 | 121 | extern const uint16_t armBitRevIndexTable_fixed_16[ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH]; 122 | extern const uint16_t armBitRevIndexTable_fixed_32[ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH]; 123 | extern const uint16_t armBitRevIndexTable_fixed_64[ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH]; 124 | extern const uint16_t armBitRevIndexTable_fixed_128[ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH]; 125 | extern const uint16_t armBitRevIndexTable_fixed_256[ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH]; 126 | extern const uint16_t armBitRevIndexTable_fixed_512[ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH]; 127 | extern const uint16_t armBitRevIndexTable_fixed_1024[ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH]; 128 | extern const uint16_t armBitRevIndexTable_fixed_2048[ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH]; 129 | extern const uint16_t armBitRevIndexTable_fixed_4096[ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH]; 130 | 131 | /* Tables for Fast Math Sine and Cosine */ 132 | extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1]; 133 | extern const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1]; 134 | extern const q15_t sinTable_q15[FAST_MATH_TABLE_SIZE + 1]; 135 | 136 | #endif /* ARM_COMMON_TABLES_H */ 137 | -------------------------------------------------------------------------------- /app/app.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "FreeRTOS.h" 6 | #include "task.h" 7 | #include "timers.h" 8 | #include "workqueue.h" 9 | #include "rtc.h" 10 | #include "aht20.h" 11 | #include "esp_at.h" 12 | #include "weather.h" 13 | #include "page.h" 14 | #include "app.h" 15 | 16 | #define MILLISECONDS(x) (x) 17 | #define SECONDS(x) MILLISECONDS((x) * 1000) 18 | #define MINUTES(x) SECONDS((x) * 60) 19 | #define HOURS(x) MINUTES((x) * 60) 20 | #define DAYS(x) HOURS((x) * 24) 21 | 22 | #define TIME_SYNC_INTERVAL HOURS(1) 23 | #define WIFI_UPDATE_INTERVAL SECONDS(5) 24 | #define TIME_UPDATE_INTERVAL SECONDS(1) 25 | #define INNER_UPDATE_INTERVAL SECONDS(3) 26 | #define OUTDOOR_UPDATE_INTERVAL MINUTES(1) 27 | 28 | #define MLOOP_EVT_TIME_SYNC (1 << 0) 29 | #define MLOOP_EVT_WIFI_UPDATE (1 << 1) 30 | #define MLOOP_EVT_INNER_UPDATE (1 << 2) 31 | #define MLOOP_EVT_OUTDOOR_UPDATE (1 << 3) 32 | #define MLOOP_EVT_ALL (MLOOP_EVT_TIME_SYNC | \ 33 | MLOOP_EVT_WIFI_UPDATE | \ 34 | MLOOP_EVT_INNER_UPDATE | \ 35 | MLOOP_EVT_OUTDOOR_UPDATE) 36 | 37 | static TimerHandle_t time_sync_timer; 38 | static TimerHandle_t wifi_update_timer; 39 | static TimerHandle_t time_update_timer; 40 | static TimerHandle_t inner_update_timer; 41 | static TimerHandle_t outdoor_update_timer; 42 | 43 | static void time_sync(void) 44 | { 45 | uint32_t restart_sync_delay = TIME_SYNC_INTERVAL; 46 | rtc_date_time_t rtc_date = { 0 }; 47 | 48 | esp_date_time_t esp_date = { 0 }; 49 | if (!esp_at_sntp_get_time(&esp_date)) 50 | { 51 | printf("[SNTP] get time failed\n"); 52 | restart_sync_delay = SECONDS(1); 53 | goto err; 54 | } 55 | 56 | if (esp_date.year < 2000) 57 | { 58 | printf("[SNTP] invalid date formate\n"); 59 | restart_sync_delay = SECONDS(1); 60 | goto err; 61 | } 62 | 63 | printf("[SNTP] sync time: %04u-%02u-%02u %02u:%02u:%02u (%d)\n", 64 | esp_date.year, esp_date.month, esp_date.day, 65 | esp_date.hour, esp_date.minute, esp_date.second, esp_date.weekday); 66 | 67 | rtc_date.year = esp_date.year; 68 | rtc_date.month = esp_date.month; 69 | rtc_date.day = esp_date.day; 70 | rtc_date.hour = esp_date.hour; 71 | rtc_date.minute = esp_date.minute; 72 | rtc_date.second = esp_date.second; 73 | rtc_date.weekday = esp_date.weekday; 74 | rtc_set_time(&rtc_date); 75 | 76 | err: 77 | xTimerChangePeriod(time_sync_timer, pdMS_TO_TICKS(restart_sync_delay), 0); 78 | } 79 | 80 | static void wifi_update(void) 81 | { 82 | static esp_wifi_info_t last_info = { 0 }; 83 | 84 | esp_wifi_info_t info = { 0 }; 85 | if (!esp_at_get_wifi_info(&info)) 86 | { 87 | printf("[AT] wifi info get failed\n"); 88 | return; 89 | } 90 | 91 | if (memcmp(&info, &last_info, sizeof(esp_wifi_info_t)) == 0) 92 | { 93 | return; 94 | } 95 | 96 | if (last_info.connected == info.connected) 97 | { 98 | return; 99 | } 100 | 101 | if (info.connected) 102 | { 103 | printf("[WIFI] connected to %s\n", info.ssid); 104 | printf("[WIFI] SSID: %s, BSSID: %s, Channel: %d, RSSI: %d\n", 105 | info.ssid, info.bssid, info.channel, info.rssi); 106 | main_page_redraw_wifi_ssid(info.ssid); 107 | } 108 | else 109 | { 110 | printf("[WIFI] disconnected from %s\n", last_info.ssid); 111 | main_page_redraw_wifi_ssid("wifi lost"); 112 | } 113 | 114 | memcpy(&last_info, &info, sizeof(esp_wifi_info_t)); 115 | } 116 | 117 | static void time_update(void) 118 | { 119 | static rtc_date_time_t last_date = { 0 }; 120 | 121 | rtc_date_time_t date; 122 | rtc_get_time(&date); 123 | 124 | if (date.year < 2020) 125 | { 126 | return; 127 | } 128 | 129 | if (memcmp(&date, &last_date, sizeof(rtc_date_time_t)) == 0) 130 | { 131 | return; 132 | } 133 | 134 | memcpy(&last_date, &date, sizeof(rtc_date_time_t)); 135 | main_page_redraw_time(&date); 136 | main_page_redraw_date(&date); 137 | } 138 | 139 | static void inner_update(void) 140 | { 141 | static float last_temperature, last_humidity; 142 | 143 | if (!aht20_start_measurement()) 144 | { 145 | printf("[AHT20] start measurement failed\n"); 146 | return; 147 | } 148 | 149 | if (!aht20_wait_for_measurement()) 150 | { 151 | printf("[AHT20] wait for measurement failed\n"); 152 | return; 153 | } 154 | 155 | float temperature = 0.0f, humidity = 0.0f; 156 | 157 | if (!aht20_read_measurement(&temperature, &humidity)) 158 | { 159 | printf("[AHT20] read measurement failed\n"); 160 | return; 161 | } 162 | 163 | if (temperature == last_temperature && humidity == last_humidity) 164 | { 165 | return; 166 | } 167 | 168 | last_temperature = temperature; 169 | last_humidity = humidity; 170 | 171 | printf("[AHT20] Temperature: %.1f, Humidity: %.1f\n", temperature, humidity); 172 | main_page_redraw_inner_temperature(temperature); 173 | main_page_redraw_inner_humidity(humidity); 174 | } 175 | 176 | static void outdoor_update(void) 177 | { 178 | static weather_info_t last_weather = { 0 }; 179 | 180 | weather_info_t weather = { 0 }; 181 | const char *weather_url = "https://api.seniverse.com/v3/weather/now.json?key=SfRic8Wmp-Qh3OeFk&location=WTEMH46Z5N09&language=en&unit=c"; 182 | const char *weather_http_response = esp_at_http_get(weather_url); 183 | if (weather_http_response == NULL) 184 | { 185 | printf("[WEATHER] http error\n"); 186 | return; 187 | } 188 | 189 | if (!parse_seniverse_response(weather_http_response, &weather)) 190 | { 191 | printf("[WEATHER] parse failed\n"); 192 | return; 193 | } 194 | 195 | if (memcmp(&last_weather, &weather, sizeof(weather_info_t)) == 0) 196 | { 197 | return; 198 | } 199 | 200 | memcpy(&last_weather, &weather, sizeof(weather_info_t)); 201 | printf("[WEATHER] %s, %s, %.1f\n", weather.city, weather.weather, weather.temperature); 202 | 203 | main_page_redraw_outdoor_temperature(weather.temperature); 204 | main_page_redraw_outdoor_weather_icon(weather.weather_code); 205 | } 206 | 207 | typedef void (*app_job_t)(void); 208 | 209 | static void app_work(void *param) 210 | { 211 | app_job_t job = (app_job_t)param; 212 | job(); 213 | } 214 | 215 | static void work_timer_cb(TimerHandle_t timer) 216 | { 217 | app_job_t job = (app_job_t)pvTimerGetTimerID(timer); 218 | workqueue_run(app_work, job); 219 | } 220 | 221 | static void app_timer_cb(TimerHandle_t timer) 222 | { 223 | app_job_t job = (app_job_t)pvTimerGetTimerID(timer); 224 | job(); 225 | } 226 | 227 | void app_init(void) 228 | { 229 | time_update_timer = xTimerCreate("time update", pdMS_TO_TICKS(TIME_UPDATE_INTERVAL), pdTRUE, time_update, app_timer_cb); 230 | time_sync_timer = xTimerCreate("time sync", pdMS_TO_TICKS(200), pdFALSE, time_sync, work_timer_cb); 231 | wifi_update_timer = xTimerCreate("wifi update", pdMS_TO_TICKS(WIFI_UPDATE_INTERVAL), pdTRUE, wifi_update, work_timer_cb); 232 | inner_update_timer = xTimerCreate("inner upadte", pdMS_TO_TICKS(INNER_UPDATE_INTERVAL), pdTRUE, inner_update, work_timer_cb); 233 | outdoor_update_timer = xTimerCreate("outdoor update", pdMS_TO_TICKS(OUTDOOR_UPDATE_INTERVAL), pdTRUE, outdoor_update, work_timer_cb); 234 | 235 | workqueue_run(app_work, time_sync); 236 | workqueue_run(app_work, wifi_update); 237 | workqueue_run(app_work, inner_update); 238 | workqueue_run(app_work, outdoor_update); 239 | 240 | xTimerStart(time_update_timer, 0); 241 | xTimerStart(time_sync_timer, 0); 242 | xTimerStart(wifi_update_timer, 0); 243 | xTimerStart(inner_update_timer, 0); 244 | xTimerStart(outdoor_update_timer, 0); 245 | } 246 | -------------------------------------------------------------------------------- /firmware/driver/inc/stm32f4xx_exti.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_exti.h 4 | * @author MCD Application Team 5 | * @version V1.8.1 6 | * @date 27-January-2022 7 | * @brief This file contains all the functions prototypes for the EXTI firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * Copyright (c) 2016 STMicroelectronics. 13 | * All rights reserved. 14 | * 15 | * This software is licensed under terms that can be found in the LICENSE file 16 | * in the root directory of this software component. 17 | * If no LICENSE file comes with this software, it is provided AS-IS. 18 | * 19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F4xx_EXTI_H 24 | #define __STM32F4xx_EXTI_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f4xx.h" 32 | 33 | /** @addtogroup STM32F4xx_StdPeriph_Driver 34 | * @{ 35 | */ 36 | 37 | /** @addtogroup EXTI 38 | * @{ 39 | */ 40 | 41 | /* Exported types ------------------------------------------------------------*/ 42 | 43 | /** 44 | * @brief EXTI mode enumeration 45 | */ 46 | 47 | typedef enum 48 | { 49 | EXTI_Mode_Interrupt = 0x00, 50 | EXTI_Mode_Event = 0x04 51 | }EXTIMode_TypeDef; 52 | 53 | #define IS_EXTI_MODE(MODE) (((MODE) == EXTI_Mode_Interrupt) || ((MODE) == EXTI_Mode_Event)) 54 | 55 | /** 56 | * @brief EXTI Trigger enumeration 57 | */ 58 | 59 | typedef enum 60 | { 61 | EXTI_Trigger_Rising = 0x08, 62 | EXTI_Trigger_Falling = 0x0C, 63 | EXTI_Trigger_Rising_Falling = 0x10 64 | }EXTITrigger_TypeDef; 65 | 66 | #define IS_EXTI_TRIGGER(TRIGGER) (((TRIGGER) == EXTI_Trigger_Rising) || \ 67 | ((TRIGGER) == EXTI_Trigger_Falling) || \ 68 | ((TRIGGER) == EXTI_Trigger_Rising_Falling)) 69 | /** 70 | * @brief EXTI Init Structure definition 71 | */ 72 | 73 | typedef struct 74 | { 75 | uint32_t EXTI_Line; /*!< Specifies the EXTI lines to be enabled or disabled. 76 | This parameter can be any combination value of @ref EXTI_Lines */ 77 | 78 | EXTIMode_TypeDef EXTI_Mode; /*!< Specifies the mode for the EXTI lines. 79 | This parameter can be a value of @ref EXTIMode_TypeDef */ 80 | 81 | EXTITrigger_TypeDef EXTI_Trigger; /*!< Specifies the trigger signal active edge for the EXTI lines. 82 | This parameter can be a value of @ref EXTITrigger_TypeDef */ 83 | 84 | FunctionalState EXTI_LineCmd; /*!< Specifies the new state of the selected EXTI lines. 85 | This parameter can be set either to ENABLE or DISABLE */ 86 | }EXTI_InitTypeDef; 87 | 88 | /* Exported constants --------------------------------------------------------*/ 89 | 90 | /** @defgroup EXTI_Exported_Constants 91 | * @{ 92 | */ 93 | 94 | /** @defgroup EXTI_Lines 95 | * @{ 96 | */ 97 | 98 | #define EXTI_Line0 ((uint32_t)0x00001) /*!< External interrupt line 0 */ 99 | #define EXTI_Line1 ((uint32_t)0x00002) /*!< External interrupt line 1 */ 100 | #define EXTI_Line2 ((uint32_t)0x00004) /*!< External interrupt line 2 */ 101 | #define EXTI_Line3 ((uint32_t)0x00008) /*!< External interrupt line 3 */ 102 | #define EXTI_Line4 ((uint32_t)0x00010) /*!< External interrupt line 4 */ 103 | #define EXTI_Line5 ((uint32_t)0x00020) /*!< External interrupt line 5 */ 104 | #define EXTI_Line6 ((uint32_t)0x00040) /*!< External interrupt line 6 */ 105 | #define EXTI_Line7 ((uint32_t)0x00080) /*!< External interrupt line 7 */ 106 | #define EXTI_Line8 ((uint32_t)0x00100) /*!< External interrupt line 8 */ 107 | #define EXTI_Line9 ((uint32_t)0x00200) /*!< External interrupt line 9 */ 108 | #define EXTI_Line10 ((uint32_t)0x00400) /*!< External interrupt line 10 */ 109 | #define EXTI_Line11 ((uint32_t)0x00800) /*!< External interrupt line 11 */ 110 | #define EXTI_Line12 ((uint32_t)0x01000) /*!< External interrupt line 12 */ 111 | #define EXTI_Line13 ((uint32_t)0x02000) /*!< External interrupt line 13 */ 112 | #define EXTI_Line14 ((uint32_t)0x04000) /*!< External interrupt line 14 */ 113 | #define EXTI_Line15 ((uint32_t)0x08000) /*!< External interrupt line 15 */ 114 | #define EXTI_Line16 ((uint32_t)0x10000) /*!< External interrupt line 16 Connected to the PVD Output */ 115 | #define EXTI_Line17 ((uint32_t)0x20000) /*!< External interrupt line 17 Connected to the RTC Alarm event */ 116 | #define EXTI_Line18 ((uint32_t)0x40000) /*!< External interrupt line 18 Connected to the USB OTG FS Wakeup from suspend event */ 117 | #define EXTI_Line19 ((uint32_t)0x80000) /*!< External interrupt line 19 Connected to the Ethernet Wakeup event */ 118 | #define EXTI_Line20 ((uint32_t)0x00100000) /*!< External interrupt line 20 Connected to the USB OTG HS (configured in FS) Wakeup event */ 119 | #define EXTI_Line21 ((uint32_t)0x00200000) /*!< External interrupt line 21 Connected to the RTC Tamper and Time Stamp events */ 120 | #define EXTI_Line22 ((uint32_t)0x00400000) /*!< External interrupt line 22 Connected to the RTC Wakeup event */ 121 | #define EXTI_Line23 ((uint32_t)0x00800000) /*!< External interrupt line 23 Connected to the LPTIM Wakeup event */ 122 | 123 | 124 | #define IS_EXTI_LINE(LINE) ((((LINE) & (uint32_t)0xFF800000) == 0x00) && ((LINE) != (uint16_t)0x00)) 125 | 126 | #define IS_GET_EXTI_LINE(LINE) (((LINE) == EXTI_Line0) || ((LINE) == EXTI_Line1) || \ 127 | ((LINE) == EXTI_Line2) || ((LINE) == EXTI_Line3) || \ 128 | ((LINE) == EXTI_Line4) || ((LINE) == EXTI_Line5) || \ 129 | ((LINE) == EXTI_Line6) || ((LINE) == EXTI_Line7) || \ 130 | ((LINE) == EXTI_Line8) || ((LINE) == EXTI_Line9) || \ 131 | ((LINE) == EXTI_Line10) || ((LINE) == EXTI_Line11) || \ 132 | ((LINE) == EXTI_Line12) || ((LINE) == EXTI_Line13) || \ 133 | ((LINE) == EXTI_Line14) || ((LINE) == EXTI_Line15) || \ 134 | ((LINE) == EXTI_Line16) || ((LINE) == EXTI_Line17) || \ 135 | ((LINE) == EXTI_Line18) || ((LINE) == EXTI_Line19) || \ 136 | ((LINE) == EXTI_Line20) || ((LINE) == EXTI_Line21) ||\ 137 | ((LINE) == EXTI_Line22) || ((LINE) == EXTI_Line23)) 138 | 139 | /** 140 | * @} 141 | */ 142 | 143 | /** 144 | * @} 145 | */ 146 | 147 | /* Exported macro ------------------------------------------------------------*/ 148 | /* Exported functions --------------------------------------------------------*/ 149 | 150 | /* Function used to set the EXTI configuration to the default reset state *****/ 151 | void EXTI_DeInit(void); 152 | 153 | /* Initialization and Configuration functions *********************************/ 154 | void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct); 155 | void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct); 156 | void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line); 157 | 158 | /* Interrupts and flags management functions **********************************/ 159 | FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line); 160 | void EXTI_ClearFlag(uint32_t EXTI_Line); 161 | ITStatus EXTI_GetITStatus(uint32_t EXTI_Line); 162 | void EXTI_ClearITPendingBit(uint32_t EXTI_Line); 163 | 164 | #ifdef __cplusplus 165 | } 166 | #endif 167 | 168 | #endif /* __STM32F4xx_EXTI_H */ 169 | 170 | /** 171 | * @} 172 | */ 173 | 174 | /** 175 | * @} 176 | */ 177 | 178 | -------------------------------------------------------------------------------- /third_lib/freertos/include/stack_macros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.4.3 LTS Patch 3 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * https://www.FreeRTOS.org 23 | * https://github.com/FreeRTOS 24 | * 25 | */ 26 | 27 | #ifndef STACK_MACROS_H 28 | #define STACK_MACROS_H 29 | 30 | /* 31 | * Call the stack overflow hook function if the stack of the task being swapped 32 | * out is currently overflowed, or looks like it might have overflowed in the 33 | * past. 34 | * 35 | * Setting configCHECK_FOR_STACK_OVERFLOW to 1 will cause the macro to check 36 | * the current stack state only - comparing the current top of stack value to 37 | * the stack limit. Setting configCHECK_FOR_STACK_OVERFLOW to greater than 1 38 | * will also cause the last few stack bytes to be checked to ensure the value 39 | * to which the bytes were set when the task was created have not been 40 | * overwritten. Note this second test does not guarantee that an overflowed 41 | * stack will always be recognised. 42 | */ 43 | 44 | /*-----------------------------------------------------------*/ 45 | 46 | #if ( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH < 0 ) ) 47 | 48 | /* Only the current stack state is to be checked. */ 49 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 50 | { \ 51 | /* Is the currently saved stack pointer within the stack limit? */ \ 52 | if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \ 53 | { \ 54 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 55 | } \ 56 | } 57 | 58 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ 59 | /*-----------------------------------------------------------*/ 60 | 61 | #if ( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH > 0 ) ) 62 | 63 | /* Only the current stack state is to be checked. */ 64 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 65 | { \ 66 | \ 67 | /* Is the currently saved stack pointer within the stack limit? */ \ 68 | if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \ 69 | { \ 70 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 71 | } \ 72 | } 73 | 74 | #endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */ 75 | /*-----------------------------------------------------------*/ 76 | 77 | #if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) ) 78 | 79 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 80 | { \ 81 | const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \ 82 | const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5; \ 83 | \ 84 | if( ( pulStack[ 0 ] != ulCheckValue ) || \ 85 | ( pulStack[ 1 ] != ulCheckValue ) || \ 86 | ( pulStack[ 2 ] != ulCheckValue ) || \ 87 | ( pulStack[ 3 ] != ulCheckValue ) ) \ 88 | { \ 89 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 90 | } \ 91 | } 92 | 93 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ 94 | /*-----------------------------------------------------------*/ 95 | 96 | #if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) 97 | 98 | #define taskCHECK_FOR_STACK_OVERFLOW() \ 99 | { \ 100 | int8_t * pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack; \ 101 | static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 102 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 103 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 104 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ 105 | tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ 106 | \ 107 | \ 108 | pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ 109 | \ 110 | /* Has the extremity of the task stack ever been written over? */ \ 111 | if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ 112 | { \ 113 | vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ 114 | } \ 115 | } 116 | 117 | #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ 118 | /*-----------------------------------------------------------*/ 119 | 120 | /* Remove stack overflow macro if not being used. */ 121 | #ifndef taskCHECK_FOR_STACK_OVERFLOW 122 | #define taskCHECK_FOR_STACK_OVERFLOW() 123 | #endif 124 | 125 | 126 | 127 | #endif /* STACK_MACROS_H */ 128 | -------------------------------------------------------------------------------- /third_lib/freertos/include/deprecated_definitions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.4.3 LTS Patch 3 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * https://www.FreeRTOS.org 23 | * https://github.com/FreeRTOS 24 | * 25 | */ 26 | 27 | #ifndef DEPRECATED_DEFINITIONS_H 28 | #define DEPRECATED_DEFINITIONS_H 29 | 30 | 31 | /* Each FreeRTOS port has a unique portmacro.h header file. Originally a 32 | * pre-processor definition was used to ensure the pre-processor found the correct 33 | * portmacro.h file for the port being used. That scheme was deprecated in favour 34 | * of setting the compiler's include path such that it found the correct 35 | * portmacro.h file - removing the need for the constant and allowing the 36 | * portmacro.h file to be located anywhere in relation to the port being used. The 37 | * definitions below remain in the code for backward compatibility only. New 38 | * projects should not use them. */ 39 | 40 | #ifdef OPEN_WATCOM_INDUSTRIAL_PC_PORT 41 | #include "..\..\Source\portable\owatcom\16bitdos\pc\portmacro.h" 42 | typedef void ( __interrupt __far * pxISR )(); 43 | #endif 44 | 45 | #ifdef OPEN_WATCOM_FLASH_LITE_186_PORT 46 | #include "..\..\Source\portable\owatcom\16bitdos\flsh186\portmacro.h" 47 | typedef void ( __interrupt __far * pxISR )(); 48 | #endif 49 | 50 | #ifdef GCC_MEGA_AVR 51 | #include "../portable/GCC/ATMega323/portmacro.h" 52 | #endif 53 | 54 | #ifdef IAR_MEGA_AVR 55 | #include "../portable/IAR/ATMega323/portmacro.h" 56 | #endif 57 | 58 | #ifdef MPLAB_PIC24_PORT 59 | #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" 60 | #endif 61 | 62 | #ifdef MPLAB_DSPIC_PORT 63 | #include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h" 64 | #endif 65 | 66 | #ifdef MPLAB_PIC18F_PORT 67 | #include "../../Source/portable/MPLAB/PIC18F/portmacro.h" 68 | #endif 69 | 70 | #ifdef MPLAB_PIC32MX_PORT 71 | #include "../../Source/portable/MPLAB/PIC32MX/portmacro.h" 72 | #endif 73 | 74 | #ifdef _FEDPICC 75 | #include "libFreeRTOS/Include/portmacro.h" 76 | #endif 77 | 78 | #ifdef SDCC_CYGNAL 79 | #include "../../Source/portable/SDCC/Cygnal/portmacro.h" 80 | #endif 81 | 82 | #ifdef GCC_ARM7 83 | #include "../../Source/portable/GCC/ARM7_LPC2000/portmacro.h" 84 | #endif 85 | 86 | #ifdef GCC_ARM7_ECLIPSE 87 | #include "portmacro.h" 88 | #endif 89 | 90 | #ifdef ROWLEY_LPC23xx 91 | #include "../../Source/portable/GCC/ARM7_LPC23xx/portmacro.h" 92 | #endif 93 | 94 | #ifdef IAR_MSP430 95 | #include "..\..\Source\portable\IAR\MSP430\portmacro.h" 96 | #endif 97 | 98 | #ifdef GCC_MSP430 99 | #include "../../Source/portable/GCC/MSP430F449/portmacro.h" 100 | #endif 101 | 102 | #ifdef ROWLEY_MSP430 103 | #include "../../Source/portable/Rowley/MSP430F449/portmacro.h" 104 | #endif 105 | 106 | #ifdef ARM7_LPC21xx_KEIL_RVDS 107 | #include "..\..\Source\portable\RVDS\ARM7_LPC21xx\portmacro.h" 108 | #endif 109 | 110 | #ifdef SAM7_GCC 111 | #include "../../Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h" 112 | #endif 113 | 114 | #ifdef SAM7_IAR 115 | #include "..\..\Source\portable\IAR\AtmelSAM7S64\portmacro.h" 116 | #endif 117 | 118 | #ifdef SAM9XE_IAR 119 | #include "..\..\Source\portable\IAR\AtmelSAM9XE\portmacro.h" 120 | #endif 121 | 122 | #ifdef LPC2000_IAR 123 | #include "..\..\Source\portable\IAR\LPC2000\portmacro.h" 124 | #endif 125 | 126 | #ifdef STR71X_IAR 127 | #include "..\..\Source\portable\IAR\STR71x\portmacro.h" 128 | #endif 129 | 130 | #ifdef STR75X_IAR 131 | #include "..\..\Source\portable\IAR\STR75x\portmacro.h" 132 | #endif 133 | 134 | #ifdef STR75X_GCC 135 | #include "..\..\Source\portable\GCC\STR75x\portmacro.h" 136 | #endif 137 | 138 | #ifdef STR91X_IAR 139 | #include "..\..\Source\portable\IAR\STR91x\portmacro.h" 140 | #endif 141 | 142 | #ifdef GCC_H8S 143 | #include "../../Source/portable/GCC/H8S2329/portmacro.h" 144 | #endif 145 | 146 | #ifdef GCC_AT91FR40008 147 | #include "../../Source/portable/GCC/ARM7_AT91FR40008/portmacro.h" 148 | #endif 149 | 150 | #ifdef RVDS_ARMCM3_LM3S102 151 | #include "../../Source/portable/RVDS/ARM_CM3/portmacro.h" 152 | #endif 153 | 154 | #ifdef GCC_ARMCM3_LM3S102 155 | #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" 156 | #endif 157 | 158 | #ifdef GCC_ARMCM3 159 | #include "../../Source/portable/GCC/ARM_CM3/portmacro.h" 160 | #endif 161 | 162 | #ifdef IAR_ARM_CM3 163 | #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" 164 | #endif 165 | 166 | #ifdef IAR_ARMCM3_LM 167 | #include "../../Source/portable/IAR/ARM_CM3/portmacro.h" 168 | #endif 169 | 170 | #ifdef HCS12_CODE_WARRIOR 171 | #include "../../Source/portable/CodeWarrior/HCS12/portmacro.h" 172 | #endif 173 | 174 | #ifdef MICROBLAZE_GCC 175 | #include "../../Source/portable/GCC/MicroBlaze/portmacro.h" 176 | #endif 177 | 178 | #ifdef TERN_EE 179 | #include "..\..\Source\portable\Paradigm\Tern_EE\small\portmacro.h" 180 | #endif 181 | 182 | #ifdef GCC_HCS12 183 | #include "../../Source/portable/GCC/HCS12/portmacro.h" 184 | #endif 185 | 186 | #ifdef GCC_MCF5235 187 | #include "../../Source/portable/GCC/MCF5235/portmacro.h" 188 | #endif 189 | 190 | #ifdef COLDFIRE_V2_GCC 191 | #include "../../../Source/portable/GCC/ColdFire_V2/portmacro.h" 192 | #endif 193 | 194 | #ifdef COLDFIRE_V2_CODEWARRIOR 195 | #include "../../Source/portable/CodeWarrior/ColdFire_V2/portmacro.h" 196 | #endif 197 | 198 | #ifdef GCC_PPC405 199 | #include "../../Source/portable/GCC/PPC405_Xilinx/portmacro.h" 200 | #endif 201 | 202 | #ifdef GCC_PPC440 203 | #include "../../Source/portable/GCC/PPC440_Xilinx/portmacro.h" 204 | #endif 205 | 206 | #ifdef _16FX_SOFTUNE 207 | #include "..\..\Source\portable\Softune\MB96340\portmacro.h" 208 | #endif 209 | 210 | #ifdef BCC_INDUSTRIAL_PC_PORT 211 | 212 | /* A short file name has to be used in place of the normal 213 | * FreeRTOSConfig.h when using the Borland compiler. */ 214 | #include "frconfig.h" 215 | #include "..\portable\BCC\16BitDOS\PC\prtmacro.h" 216 | typedef void ( __interrupt __far * pxISR )(); 217 | #endif 218 | 219 | #ifdef BCC_FLASH_LITE_186_PORT 220 | 221 | /* A short file name has to be used in place of the normal 222 | * FreeRTOSConfig.h when using the Borland compiler. */ 223 | #include "frconfig.h" 224 | #include "..\portable\BCC\16BitDOS\flsh186\prtmacro.h" 225 | typedef void ( __interrupt __far * pxISR )(); 226 | #endif 227 | 228 | #ifdef __GNUC__ 229 | #ifdef __AVR32_AVR32A__ 230 | #include "portmacro.h" 231 | #endif 232 | #endif 233 | 234 | #ifdef __ICCAVR32__ 235 | #ifdef __CORE__ 236 | #if __CORE__ == __AVR32A__ 237 | #include "portmacro.h" 238 | #endif 239 | #endif 240 | #endif 241 | 242 | #ifdef __91467D 243 | #include "portmacro.h" 244 | #endif 245 | 246 | #ifdef __96340 247 | #include "portmacro.h" 248 | #endif 249 | 250 | 251 | #ifdef __IAR_V850ES_Fx3__ 252 | #include "../../Source/portable/IAR/V850ES/portmacro.h" 253 | #endif 254 | 255 | #ifdef __IAR_V850ES_Jx3__ 256 | #include "../../Source/portable/IAR/V850ES/portmacro.h" 257 | #endif 258 | 259 | #ifdef __IAR_V850ES_Jx3_L__ 260 | #include "../../Source/portable/IAR/V850ES/portmacro.h" 261 | #endif 262 | 263 | #ifdef __IAR_V850ES_Jx2__ 264 | #include "../../Source/portable/IAR/V850ES/portmacro.h" 265 | #endif 266 | 267 | #ifdef __IAR_V850ES_Hx2__ 268 | #include "../../Source/portable/IAR/V850ES/portmacro.h" 269 | #endif 270 | 271 | #ifdef __IAR_78K0R_Kx3__ 272 | #include "../../Source/portable/IAR/78K0R/portmacro.h" 273 | #endif 274 | 275 | #ifdef __IAR_78K0R_Kx3L__ 276 | #include "../../Source/portable/IAR/78K0R/portmacro.h" 277 | #endif 278 | 279 | #endif /* DEPRECATED_DEFINITIONS_H */ 280 | -------------------------------------------------------------------------------- /app/font/font16_maple.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "font.h" 3 | 4 | static const uint8_t ascii_model[] = { 5 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",0*/ 6 | 0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00,/*"!",1*/ 7 | 0x00,0x00,0x00,0x24,0x24,0x24,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*""",2*/ 8 | 0x00,0x00,0x00,0x34,0x24,0x7E,0xFF,0x24,0x24,0xFF,0x24,0x2C,0x00,0x00,0x00,0x00,/*"#",3*/ 9 | 0x00,0x00,0x18,0x3C,0x7E,0x58,0x60,0x3C,0x26,0x1A,0x5A,0x3C,0x18,0x00,0x00,0x00,/*"$",4*/ 10 | 0x00,0x00,0x00,0x70,0x53,0xD6,0x74,0x20,0x2E,0x6B,0x4B,0x8E,0x00,0x00,0x00,0x00,/*"%",5*/ 11 | 0x00,0x00,0x00,0x38,0x6C,0x40,0x20,0x50,0x4A,0x4A,0x44,0x7B,0x00,0x00,0x00,0x00,/*"&",6*/ 12 | 0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"'",7*/ 13 | 0x00,0x00,0x0C,0x18,0x10,0x30,0x20,0x20,0x20,0x20,0x30,0x10,0x08,0x04,0x00,0x00,/*"(",8*/ 14 | 0x00,0x00,0x30,0x18,0x08,0x0C,0x04,0x04,0x04,0x04,0x0C,0x18,0x10,0x20,0x00,0x00,/*")",9*/ 15 | 0x00,0x00,0x00,0x00,0x00,0x18,0x5A,0x3C,0x3C,0x5A,0x18,0x00,0x00,0x00,0x00,0x00,/*"*",10*/ 16 | 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x7E,0x7E,0x18,0x18,0x00,0x00,0x00,0x00,0x00,/*"+",11*/ 17 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x08,0x18,0x60,0x00,/*",",12*/ 18 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"-",13*/ 19 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,/*".",14*/ 20 | 0x00,0x00,0x02,0x04,0x04,0x0C,0x08,0x18,0x10,0x10,0x30,0x20,0x60,0x40,0x00,0x00,/*"/",15*/ 21 | 0x00,0x00,0x00,0x3C,0x26,0x42,0x4E,0x5A,0x72,0x62,0x66,0x3C,0x00,0x00,0x00,0x00,/*"0",16*/ 22 | 0x00,0x00,0x00,0x18,0x68,0x48,0x08,0x08,0x08,0x08,0x08,0x7E,0x00,0x00,0x00,0x00,/*"1",17*/ 23 | 0x00,0x00,0x00,0x3C,0x46,0x02,0x06,0x04,0x08,0x10,0x60,0x7E,0x00,0x00,0x00,0x00,/*"2",18*/ 24 | 0x00,0x00,0x00,0x38,0x44,0x06,0x04,0x3C,0x06,0x02,0x06,0x7C,0x00,0x00,0x00,0x00,/*"3",19*/ 25 | 0x00,0x00,0x00,0x04,0x0C,0x14,0x34,0x24,0x64,0x7E,0x04,0x04,0x00,0x00,0x00,0x00,/*"4",20*/ 26 | 0x00,0x00,0x00,0x3E,0x60,0x60,0x60,0x3C,0x06,0x02,0x06,0x7C,0x00,0x00,0x00,0x00,/*"5",21*/ 27 | 0x00,0x00,0x00,0x08,0x10,0x20,0x60,0x7E,0x42,0x42,0x66,0x3C,0x00,0x00,0x00,0x00,/*"6",22*/ 28 | 0x00,0x00,0x00,0x7E,0x02,0x04,0x04,0x0C,0x08,0x18,0x10,0x30,0x00,0x00,0x00,0x00,/*"7",23*/ 29 | 0x00,0x00,0x00,0x3C,0x66,0x42,0x66,0x3C,0x42,0x42,0x42,0x3C,0x00,0x00,0x00,0x00,/*"8",24*/ 30 | 0x00,0x00,0x00,0x3C,0x66,0x42,0x42,0x66,0x3A,0x04,0x08,0x10,0x00,0x00,0x00,0x00,/*"9",25*/ 31 | 0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,/*":",26*/ 32 | 0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x08,0x18,0x60,0x00,/*";",27*/ 33 | 0x00,0x00,0x00,0x00,0x00,0x06,0x1C,0x70,0x70,0x1C,0x06,0x00,0x00,0x00,0x00,0x00,/*"<",28*/ 34 | 0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,/*"=",29*/ 35 | 0x00,0x00,0x00,0x00,0x00,0x60,0x38,0x0E,0x0E,0x38,0x60,0x00,0x00,0x00,0x00,0x00,/*">",30*/ 36 | 0x00,0x00,0x00,0x3C,0x26,0x42,0x06,0x08,0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00,/*"?",31*/ 37 | 0x00,0x00,0x00,0x00,0x7C,0x86,0x22,0x7A,0x4B,0x48,0x48,0x6F,0x00,0x00,0x00,0x00,/*"@",32*/ 38 | 0x00,0x00,0x00,0x18,0x18,0x18,0x24,0x24,0x24,0x7E,0x42,0x42,0x00,0x00,0x00,0x00,/*"A",33*/ 39 | 0x00,0x00,0x00,0x7C,0x66,0x42,0x46,0x7C,0x42,0x42,0x46,0x7C,0x00,0x00,0x00,0x00,/*"B",34*/ 40 | 0x00,0x00,0x00,0x1C,0x22,0x40,0x40,0x40,0x40,0x40,0x20,0x3E,0x00,0x00,0x00,0x00,/*"C",35*/ 41 | 0x00,0x00,0x00,0x78,0x64,0x42,0x42,0x42,0x42,0x42,0x44,0x7C,0x00,0x00,0x00,0x00,/*"D",36*/ 42 | 0x00,0x00,0x00,0x3E,0x60,0x60,0x60,0x7E,0x60,0x60,0x60,0x7E,0x00,0x00,0x00,0x00,/*"E",37*/ 43 | 0x00,0x00,0x00,0x7E,0x60,0x40,0x40,0x7E,0x40,0x40,0x40,0x40,0x00,0x00,0x00,0x00,/*"F",38*/ 44 | 0x00,0x00,0x00,0x3C,0x66,0x42,0x40,0x4E,0x42,0x42,0x66,0x3C,0x00,0x00,0x00,0x00,/*"G",39*/ 45 | 0x00,0x00,0x00,0x42,0x42,0x42,0x42,0x7E,0x42,0x42,0x42,0x42,0x00,0x00,0x00,0x00,/*"H",40*/ 46 | 0x00,0x00,0x00,0x7E,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x7E,0x00,0x00,0x00,0x00,/*"I",41*/ 47 | 0x00,0x00,0x00,0x3C,0x06,0x06,0x06,0x06,0x06,0x46,0x44,0x3C,0x00,0x00,0x00,0x00,/*"J",42*/ 48 | 0x00,0x00,0x00,0x46,0x44,0x48,0x50,0x70,0x78,0x4C,0x44,0x42,0x00,0x00,0x00,0x00,/*"K",43*/ 49 | 0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3E,0x00,0x00,0x00,0x00,/*"L",44*/ 50 | 0x00,0x00,0x00,0x66,0x66,0x66,0x5A,0x5A,0x5A,0x42,0x42,0x42,0x00,0x00,0x00,0x00,/*"M",45*/ 51 | 0x00,0x00,0x00,0x62,0x62,0x52,0x52,0x5A,0x4A,0x4A,0x46,0x46,0x00,0x00,0x00,0x00,/*"N",46*/ 52 | 0x00,0x00,0x00,0x3C,0x64,0x42,0x42,0x42,0x42,0x42,0x66,0x3C,0x00,0x00,0x00,0x00,/*"O",47*/ 53 | 0x00,0x00,0x00,0x7C,0x66,0x42,0x42,0x7C,0x40,0x40,0x40,0x40,0x00,0x00,0x00,0x00,/*"P",48*/ 54 | 0x00,0x00,0x00,0x3C,0x64,0x42,0x42,0x42,0x42,0x42,0x66,0x3C,0x00,0x0E,0x00,0x00,/*"Q",49*/ 55 | 0x00,0x00,0x00,0x7C,0x66,0x42,0x42,0x7C,0x48,0x44,0x46,0x42,0x00,0x00,0x00,0x00,/*"R",50*/ 56 | 0x00,0x00,0x00,0x3C,0x66,0x40,0x60,0x1C,0x06,0x02,0x62,0x3C,0x00,0x00,0x00,0x00,/*"S",51*/ 57 | 0x00,0x00,0x00,0x7E,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,/*"T",52*/ 58 | 0x00,0x00,0x00,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x66,0x3C,0x00,0x00,0x00,0x00,/*"U",53*/ 59 | 0x00,0x00,0x00,0x42,0x42,0x66,0x24,0x24,0x24,0x18,0x18,0x18,0x00,0x00,0x00,0x00,/*"V",54*/ 60 | 0x00,0x00,0x00,0x42,0xC3,0x5A,0x5A,0x5A,0x5A,0x6A,0x66,0x66,0x00,0x00,0x00,0x00,/*"W",55*/ 61 | 0x00,0x00,0x00,0x42,0x24,0x24,0x18,0x18,0x18,0x24,0x24,0x42,0x00,0x00,0x00,0x00,/*"X",56*/ 62 | 0x00,0x00,0x00,0x42,0x42,0x24,0x24,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,/*"Y",57*/ 63 | 0x00,0x00,0x00,0x7E,0x06,0x04,0x08,0x18,0x10,0x20,0x60,0x7E,0x00,0x00,0x00,0x00,/*"Z",58*/ 64 | 0x00,0x00,0x3C,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3C,0x00,0x00,/*"[",59*/ 65 | 0x00,0x00,0x40,0x20,0x20,0x30,0x10,0x18,0x08,0x08,0x0C,0x04,0x06,0x02,0x00,0x00,/*"\",60*/ 66 | 0x00,0x00,0x3C,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x3C,0x00,0x00,/*"]",61*/ 67 | 0x00,0x00,0x00,0x00,0x18,0x18,0x24,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"^",62*/ 68 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x00,/*"_",63*/ 69 | 0x00,0x00,0x20,0x10,0x0C,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"`",64*/ 70 | 0x00,0x00,0x00,0x00,0x00,0x1A,0x26,0x64,0x44,0x46,0x46,0x3A,0x00,0x00,0x00,0x00,/*"a",65*/ 71 | 0x00,0x00,0x00,0x40,0x40,0x58,0x64,0x62,0x42,0x42,0x66,0x5C,0x00,0x00,0x00,0x00,/*"b",66*/ 72 | 0x00,0x00,0x00,0x00,0x00,0x1C,0x36,0x40,0x40,0x40,0x60,0x3E,0x00,0x00,0x00,0x00,/*"c",67*/ 73 | 0x00,0x00,0x00,0x02,0x02,0x1A,0x26,0x46,0x42,0x42,0x66,0x3A,0x00,0x00,0x00,0x00,/*"d",68*/ 74 | 0x00,0x00,0x00,0x00,0x00,0x18,0x24,0x42,0x7E,0x40,0x64,0x3E,0x00,0x00,0x00,0x00,/*"e",69*/ 75 | 0x00,0x00,0x00,0x0E,0x10,0x10,0x7E,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00,/*"f",70*/ 76 | 0x00,0x00,0x00,0x00,0x00,0x1A,0x26,0x46,0x42,0x42,0x66,0x3A,0x02,0x64,0x3C,0x00,/*"g",71*/ 77 | 0x00,0x00,0x00,0x40,0x40,0x58,0x66,0x66,0x42,0x42,0x42,0x42,0x00,0x00,0x00,0x00,/*"h",72*/ 78 | 0x00,0x00,0x00,0x18,0x00,0x00,0x78,0x08,0x08,0x08,0x08,0x7E,0x00,0x00,0x00,0x00,/*"i",73*/ 79 | 0x00,0x00,0x00,0x0C,0x00,0x00,0x3C,0x04,0x04,0x04,0x04,0x04,0x04,0x4C,0x38,0x00,/*"j",74*/ 80 | 0x00,0x00,0x00,0x60,0x60,0x62,0x6C,0x78,0x78,0x6C,0x64,0x62,0x00,0x00,0x00,0x00,/*"k",75*/ 81 | 0x00,0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x0E,0x00,0x00,0x00,0x00,/*"l",76*/ 82 | 0x00,0x00,0x00,0x00,0x00,0x76,0x5A,0x5A,0x5A,0x5A,0x5A,0x5A,0x00,0x00,0x00,0x00,/*"m",77*/ 83 | 0x00,0x00,0x00,0x00,0x00,0x58,0x66,0x66,0x42,0x42,0x42,0x42,0x00,0x00,0x00,0x00,/*"n",78*/ 84 | 0x00,0x00,0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x66,0x3C,0x00,0x00,0x00,0x00,/*"o",79*/ 85 | 0x00,0x00,0x00,0x00,0x00,0x5C,0x76,0x42,0x42,0x42,0x66,0x5C,0x40,0x40,0x00,0x00,/*"p",80*/ 86 | 0x00,0x00,0x00,0x00,0x00,0x3A,0x6E,0x42,0x42,0x42,0x66,0x3A,0x02,0x02,0x00,0x00,/*"q",81*/ 87 | 0x00,0x00,0x00,0x00,0x00,0x2C,0x76,0x62,0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x00,/*"r",82*/ 88 | 0x00,0x00,0x00,0x00,0x00,0x18,0x66,0x60,0x3C,0x06,0x42,0x3C,0x00,0x00,0x00,0x00,/*"s",83*/ 89 | 0x00,0x00,0x00,0x00,0x10,0x10,0x7E,0x10,0x10,0x10,0x10,0x1E,0x00,0x00,0x00,0x00,/*"t",84*/ 90 | 0x00,0x00,0x00,0x00,0x00,0x42,0x42,0x42,0x42,0x42,0x66,0x3A,0x00,0x00,0x00,0x00,/*"u",85*/ 91 | 0x00,0x00,0x00,0x00,0x00,0x42,0x42,0x24,0x24,0x3C,0x18,0x18,0x00,0x00,0x00,0x00,/*"v",86*/ 92 | 0x00,0x00,0x00,0x00,0x00,0x42,0xC3,0x5A,0x5A,0x5A,0x66,0x66,0x00,0x00,0x00,0x00,/*"w",87*/ 93 | 0x00,0x00,0x00,0x00,0x00,0x42,0x24,0x3C,0x18,0x18,0x24,0x66,0x00,0x00,0x00,0x00,/*"x",88*/ 94 | 0x00,0x00,0x00,0x00,0x00,0x42,0x62,0x26,0x24,0x3C,0x18,0x18,0x18,0x30,0x60,0x00,/*"y",89*/ 95 | 0x00,0x00,0x00,0x00,0x00,0x3C,0x46,0x0C,0x18,0x10,0x20,0x7E,0x00,0x00,0x00,0x00,/*"z",90*/ 96 | 0x00,0x00,0x0E,0x10,0x10,0x10,0x18,0x70,0x10,0x18,0x10,0x10,0x18,0x0E,0x00,0x00,/*"{",91*/ 97 | 0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x10,0x00,0x00,/*"|",92*/ 98 | 0x00,0x00,0x70,0x08,0x08,0x08,0x18,0x0E,0x08,0x18,0x08,0x08,0x18,0x70,0x00,0x00,/*"}",93*/ 99 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x72,0x4E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"~",94*/}; 100 | 101 | const font_t font16_maple = { 102 | .ascii_model = ascii_model, 103 | .size = 16, 104 | }; 105 | -------------------------------------------------------------------------------- /firmware/driver/src/stm32f4xx_iwdg.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_iwdg.c 4 | * @author MCD Application Team 5 | * @version V1.8.1 6 | * @date 27-January-2022 7 | * @brief This file provides firmware functions to manage the following 8 | * functionalities of the Independent watchdog (IWDG) peripheral: 9 | * + Prescaler and Counter configuration 10 | * + IWDG activation 11 | * + Flag management 12 | * 13 | @verbatim 14 | =============================================================================== 15 | ##### IWDG features ##### 16 | =============================================================================== 17 | [..] 18 | The IWDG can be started by either software or hardware (configurable 19 | through option byte). 20 | 21 | The IWDG is clocked by its own dedicated low-speed clock (LSI) and 22 | thus stays active even if the main clock fails. 23 | Once the IWDG is started, the LSI is forced ON and cannot be disabled 24 | (LSI cannot be disabled too), and the counter starts counting down from 25 | the reset value of 0xFFF. When it reaches the end of count value (0x000) 26 | a system reset is generated. 27 | The IWDG counter should be reloaded at regular intervals to prevent 28 | an MCU reset. 29 | 30 | The IWDG is implemented in the VDD voltage domain that is still functional 31 | in STOP and STANDBY mode (IWDG reset can wake-up from STANDBY). 32 | 33 | IWDGRST flag in RCC_CSR register can be used to inform when a IWDG 34 | reset occurs. 35 | 36 | Min-max timeout value @32KHz (LSI): ~125us / ~32.7s 37 | The IWDG timeout may vary due to LSI frequency dispersion. STM32F4xx 38 | devices provide the capability to measure the LSI frequency (LSI clock 39 | connected internally to TIM5 CH4 input capture). The measured value 40 | can be used to have an IWDG timeout with an acceptable accuracy. 41 | For more information, please refer to the STM32F4xx Reference manual 42 | 43 | ##### How to use this driver ##### 44 | =============================================================================== 45 | [..] 46 | (#) Enable write access to IWDG_PR and IWDG_RLR registers using 47 | IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable) function 48 | 49 | (#) Configure the IWDG prescaler using IWDG_SetPrescaler() function 50 | 51 | (#) Configure the IWDG counter value using IWDG_SetReload() function. 52 | This value will be loaded in the IWDG counter each time the counter 53 | is reloaded, then the IWDG will start counting down from this value. 54 | 55 | (#) Start the IWDG using IWDG_Enable() function, when the IWDG is used 56 | in software mode (no need to enable the LSI, it will be enabled 57 | by hardware) 58 | 59 | (#) Then the application program must reload the IWDG counter at regular 60 | intervals during normal operation to prevent an MCU reset, using 61 | IWDG_ReloadCounter() function. 62 | 63 | @endverbatim 64 | ****************************************************************************** 65 | * @attention 66 | * 67 | * Copyright (c) 2016 STMicroelectronics. 68 | * All rights reserved. 69 | * 70 | * This software is licensed under terms that can be found in the LICENSE file 71 | * in the root directory of this software component. 72 | * If no LICENSE file comes with this software, it is provided AS-IS. 73 | * 74 | ****************************************************************************** 75 | */ 76 | 77 | /* Includes ------------------------------------------------------------------*/ 78 | #include "stm32f4xx_iwdg.h" 79 | 80 | /** @addtogroup STM32F4xx_StdPeriph_Driver 81 | * @{ 82 | */ 83 | 84 | /** @defgroup IWDG 85 | * @brief IWDG driver modules 86 | * @{ 87 | */ 88 | 89 | /* Private typedef -----------------------------------------------------------*/ 90 | /* Private define ------------------------------------------------------------*/ 91 | 92 | /* KR register bit mask */ 93 | #define KR_KEY_RELOAD ((uint16_t)0xAAAA) 94 | #define KR_KEY_ENABLE ((uint16_t)0xCCCC) 95 | 96 | /* Private macro -------------------------------------------------------------*/ 97 | /* Private variables ---------------------------------------------------------*/ 98 | /* Private function prototypes -----------------------------------------------*/ 99 | /* Private functions ---------------------------------------------------------*/ 100 | 101 | /** @defgroup IWDG_Private_Functions 102 | * @{ 103 | */ 104 | 105 | /** @defgroup IWDG_Group1 Prescaler and Counter configuration functions 106 | * @brief Prescaler and Counter configuration functions 107 | * 108 | @verbatim 109 | =============================================================================== 110 | ##### Prescaler and Counter configuration functions ##### 111 | =============================================================================== 112 | 113 | @endverbatim 114 | * @{ 115 | */ 116 | 117 | /** 118 | * @brief Enables or disables write access to IWDG_PR and IWDG_RLR registers. 119 | * @param IWDG_WriteAccess: new state of write access to IWDG_PR and IWDG_RLR registers. 120 | * This parameter can be one of the following values: 121 | * @arg IWDG_WriteAccess_Enable: Enable write access to IWDG_PR and IWDG_RLR registers 122 | * @arg IWDG_WriteAccess_Disable: Disable write access to IWDG_PR and IWDG_RLR registers 123 | * @retval None 124 | */ 125 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess) 126 | { 127 | /* Check the parameters */ 128 | assert_param(IS_IWDG_WRITE_ACCESS(IWDG_WriteAccess)); 129 | IWDG->KR = IWDG_WriteAccess; 130 | } 131 | 132 | /** 133 | * @brief Sets IWDG Prescaler value. 134 | * @param IWDG_Prescaler: specifies the IWDG Prescaler value. 135 | * This parameter can be one of the following values: 136 | * @arg IWDG_Prescaler_4: IWDG prescaler set to 4 137 | * @arg IWDG_Prescaler_8: IWDG prescaler set to 8 138 | * @arg IWDG_Prescaler_16: IWDG prescaler set to 16 139 | * @arg IWDG_Prescaler_32: IWDG prescaler set to 32 140 | * @arg IWDG_Prescaler_64: IWDG prescaler set to 64 141 | * @arg IWDG_Prescaler_128: IWDG prescaler set to 128 142 | * @arg IWDG_Prescaler_256: IWDG prescaler set to 256 143 | * @retval None 144 | */ 145 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler) 146 | { 147 | /* Check the parameters */ 148 | assert_param(IS_IWDG_PRESCALER(IWDG_Prescaler)); 149 | IWDG->PR = IWDG_Prescaler; 150 | } 151 | 152 | /** 153 | * @brief Sets IWDG Reload value. 154 | * @param Reload: specifies the IWDG Reload value. 155 | * This parameter must be a number between 0 and 0x0FFF. 156 | * @retval None 157 | */ 158 | void IWDG_SetReload(uint16_t Reload) 159 | { 160 | /* Check the parameters */ 161 | assert_param(IS_IWDG_RELOAD(Reload)); 162 | IWDG->RLR = Reload; 163 | } 164 | 165 | /** 166 | * @brief Reloads IWDG counter with value defined in the reload register 167 | * (write access to IWDG_PR and IWDG_RLR registers disabled). 168 | * @param None 169 | * @retval None 170 | */ 171 | void IWDG_ReloadCounter(void) 172 | { 173 | IWDG->KR = KR_KEY_RELOAD; 174 | } 175 | 176 | /** 177 | * @} 178 | */ 179 | 180 | /** @defgroup IWDG_Group2 IWDG activation function 181 | * @brief IWDG activation function 182 | * 183 | @verbatim 184 | =============================================================================== 185 | ##### IWDG activation function ##### 186 | =============================================================================== 187 | 188 | @endverbatim 189 | * @{ 190 | */ 191 | 192 | /** 193 | * @brief Enables IWDG (write access to IWDG_PR and IWDG_RLR registers disabled). 194 | * @param None 195 | * @retval None 196 | */ 197 | void IWDG_Enable(void) 198 | { 199 | IWDG->KR = KR_KEY_ENABLE; 200 | } 201 | 202 | /** 203 | * @} 204 | */ 205 | 206 | /** @defgroup IWDG_Group3 Flag management function 207 | * @brief Flag management function 208 | * 209 | @verbatim 210 | =============================================================================== 211 | ##### Flag management function ##### 212 | =============================================================================== 213 | 214 | @endverbatim 215 | * @{ 216 | */ 217 | 218 | /** 219 | * @brief Checks whether the specified IWDG flag is set or not. 220 | * @param IWDG_FLAG: specifies the flag to check. 221 | * This parameter can be one of the following values: 222 | * @arg IWDG_FLAG_PVU: Prescaler Value Update on going 223 | * @arg IWDG_FLAG_RVU: Reload Value Update on going 224 | * @retval The new state of IWDG_FLAG (SET or RESET). 225 | */ 226 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG) 227 | { 228 | FlagStatus bitstatus = RESET; 229 | /* Check the parameters */ 230 | assert_param(IS_IWDG_FLAG(IWDG_FLAG)); 231 | if ((IWDG->SR & IWDG_FLAG) != (uint32_t)RESET) 232 | { 233 | bitstatus = SET; 234 | } 235 | else 236 | { 237 | bitstatus = RESET; 238 | } 239 | /* Return the flag status */ 240 | return bitstatus; 241 | } 242 | 243 | /** 244 | * @} 245 | */ 246 | 247 | /** 248 | * @} 249 | */ 250 | 251 | /** 252 | * @} 253 | */ 254 | 255 | /** 256 | * @} 257 | */ 258 | 259 | -------------------------------------------------------------------------------- /third_lib/freertos/include/portable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.4.3 LTS Patch 3 3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * https://www.FreeRTOS.org 23 | * https://github.com/FreeRTOS 24 | * 25 | */ 26 | 27 | /*----------------------------------------------------------- 28 | * Portable layer API. Each function must be defined for each port. 29 | *----------------------------------------------------------*/ 30 | 31 | #ifndef PORTABLE_H 32 | #define PORTABLE_H 33 | 34 | /* Each FreeRTOS port has a unique portmacro.h header file. Originally a 35 | * pre-processor definition was used to ensure the pre-processor found the correct 36 | * portmacro.h file for the port being used. That scheme was deprecated in favour 37 | * of setting the compiler's include path such that it found the correct 38 | * portmacro.h file - removing the need for the constant and allowing the 39 | * portmacro.h file to be located anywhere in relation to the port being used. 40 | * Purely for reasons of backward compatibility the old method is still valid, but 41 | * to make it clear that new projects should not use it, support for the port 42 | * specific constants has been moved into the deprecated_definitions.h header 43 | * file. */ 44 | #include "deprecated_definitions.h" 45 | 46 | /* If portENTER_CRITICAL is not defined then including deprecated_definitions.h 47 | * did not result in a portmacro.h header file being included - and it should be 48 | * included here. In this case the path to the correct portmacro.h header file 49 | * must be set in the compiler's include path. */ 50 | #ifndef portENTER_CRITICAL 51 | #include "portmacro.h" 52 | #endif 53 | 54 | #if portBYTE_ALIGNMENT == 32 55 | #define portBYTE_ALIGNMENT_MASK ( 0x001f ) 56 | #endif 57 | 58 | #if portBYTE_ALIGNMENT == 16 59 | #define portBYTE_ALIGNMENT_MASK ( 0x000f ) 60 | #endif 61 | 62 | #if portBYTE_ALIGNMENT == 8 63 | #define portBYTE_ALIGNMENT_MASK ( 0x0007 ) 64 | #endif 65 | 66 | #if portBYTE_ALIGNMENT == 4 67 | #define portBYTE_ALIGNMENT_MASK ( 0x0003 ) 68 | #endif 69 | 70 | #if portBYTE_ALIGNMENT == 2 71 | #define portBYTE_ALIGNMENT_MASK ( 0x0001 ) 72 | #endif 73 | 74 | #if portBYTE_ALIGNMENT == 1 75 | #define portBYTE_ALIGNMENT_MASK ( 0x0000 ) 76 | #endif 77 | 78 | #ifndef portBYTE_ALIGNMENT_MASK 79 | #error "Invalid portBYTE_ALIGNMENT definition" 80 | #endif 81 | 82 | #ifndef portNUM_CONFIGURABLE_REGIONS 83 | #define portNUM_CONFIGURABLE_REGIONS 1 84 | #endif 85 | 86 | #ifndef portHAS_STACK_OVERFLOW_CHECKING 87 | #define portHAS_STACK_OVERFLOW_CHECKING 0 88 | #endif 89 | 90 | #ifndef portARCH_NAME 91 | #define portARCH_NAME NULL 92 | #endif 93 | 94 | /* *INDENT-OFF* */ 95 | #ifdef __cplusplus 96 | extern "C" { 97 | #endif 98 | /* *INDENT-ON* */ 99 | 100 | #include "mpu_wrappers.h" 101 | 102 | /* 103 | * Setup the stack of a new task so it is ready to be placed under the 104 | * scheduler control. The registers have to be placed on the stack in 105 | * the order that the port expects to find them. 106 | * 107 | */ 108 | #if ( portUSING_MPU_WRAPPERS == 1 ) 109 | #if ( portHAS_STACK_OVERFLOW_CHECKING == 1 ) 110 | StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, 111 | StackType_t * pxEndOfStack, 112 | TaskFunction_t pxCode, 113 | void * pvParameters, 114 | BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; 115 | #else 116 | StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, 117 | TaskFunction_t pxCode, 118 | void * pvParameters, 119 | BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; 120 | #endif 121 | #else /* if ( portUSING_MPU_WRAPPERS == 1 ) */ 122 | #if ( portHAS_STACK_OVERFLOW_CHECKING == 1 ) 123 | StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, 124 | StackType_t * pxEndOfStack, 125 | TaskFunction_t pxCode, 126 | void * pvParameters ) PRIVILEGED_FUNCTION; 127 | #else 128 | StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, 129 | TaskFunction_t pxCode, 130 | void * pvParameters ) PRIVILEGED_FUNCTION; 131 | #endif 132 | #endif /* if ( portUSING_MPU_WRAPPERS == 1 ) */ 133 | 134 | /* Used by heap_5.c to define the start address and size of each memory region 135 | * that together comprise the total FreeRTOS heap space. */ 136 | typedef struct HeapRegion 137 | { 138 | uint8_t * pucStartAddress; 139 | size_t xSizeInBytes; 140 | } HeapRegion_t; 141 | 142 | /* Used to pass information about the heap out of vPortGetHeapStats(). */ 143 | typedef struct xHeapStats 144 | { 145 | size_t xAvailableHeapSpaceInBytes; /* The total heap size currently available - this is the sum of all the free blocks, not the largest block that can be allocated. */ 146 | size_t xSizeOfLargestFreeBlockInBytes; /* The maximum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ 147 | size_t xSizeOfSmallestFreeBlockInBytes; /* The minimum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ 148 | size_t xNumberOfFreeBlocks; /* The number of free memory blocks within the heap at the time vPortGetHeapStats() is called. */ 149 | size_t xMinimumEverFreeBytesRemaining; /* The minimum amount of total free memory (sum of all free blocks) there has been in the heap since the system booted. */ 150 | size_t xNumberOfSuccessfulAllocations; /* The number of calls to pvPortMalloc() that have returned a valid memory block. */ 151 | size_t xNumberOfSuccessfulFrees; /* The number of calls to vPortFree() that has successfully freed a block of memory. */ 152 | } HeapStats_t; 153 | 154 | /* 155 | * Used to define multiple heap regions for use by heap_5.c. This function 156 | * must be called before any calls to pvPortMalloc() - not creating a task, 157 | * queue, semaphore, mutex, software timer, event group, etc. will result in 158 | * pvPortMalloc being called. 159 | * 160 | * pxHeapRegions passes in an array of HeapRegion_t structures - each of which 161 | * defines a region of memory that can be used as the heap. The array is 162 | * terminated by a HeapRegions_t structure that has a size of 0. The region 163 | * with the lowest start address must appear first in the array. 164 | */ 165 | void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION; 166 | 167 | /* 168 | * Returns a HeapStats_t structure filled with information about the current 169 | * heap state. 170 | */ 171 | void vPortGetHeapStats( HeapStats_t * pxHeapStats ); 172 | 173 | /* 174 | * Map to the memory management routines required for the port. 175 | */ 176 | void * pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION; 177 | void vPortFree( void * pv ) PRIVILEGED_FUNCTION; 178 | void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION; 179 | size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION; 180 | size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION; 181 | 182 | /* 183 | * Setup the hardware ready for the scheduler to take control. This generally 184 | * sets up a tick interrupt and sets timers for the correct tick frequency. 185 | */ 186 | BaseType_t xPortStartScheduler( void ) PRIVILEGED_FUNCTION; 187 | 188 | /* 189 | * Undo any hardware/ISR setup that was performed by xPortStartScheduler() so 190 | * the hardware is left in its original condition after the scheduler stops 191 | * executing. 192 | */ 193 | void vPortEndScheduler( void ) PRIVILEGED_FUNCTION; 194 | 195 | /* 196 | * The structures and methods of manipulating the MPU are contained within the 197 | * port layer. 198 | * 199 | * Fills the xMPUSettings structure with the memory region information 200 | * contained in xRegions. 201 | */ 202 | #if ( portUSING_MPU_WRAPPERS == 1 ) 203 | struct xMEMORY_REGION; 204 | void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings, 205 | const struct xMEMORY_REGION * const xRegions, 206 | StackType_t * pxBottomOfStack, 207 | uint32_t ulStackDepth ) PRIVILEGED_FUNCTION; 208 | #endif 209 | 210 | /* *INDENT-OFF* */ 211 | #ifdef __cplusplus 212 | } 213 | #endif 214 | /* *INDENT-ON* */ 215 | 216 | #endif /* PORTABLE_H */ 217 | -------------------------------------------------------------------------------- /firmware/driver/inc/stm32f4xx_pwr.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_pwr.h 4 | * @author MCD Application Team 5 | * @version V1.8.1 6 | * @date 27-January-2022 7 | * @brief This file contains all the functions prototypes for the PWR firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * Copyright (c) 2016 STMicroelectronics. 13 | * All rights reserved. 14 | * 15 | * This software is licensed under terms that can be found in the LICENSE file 16 | * in the root directory of this software component. 17 | * If no LICENSE file comes with this software, it is provided AS-IS. 18 | * 19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F4xx_PWR_H 24 | #define __STM32F4xx_PWR_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f4xx.h" 32 | 33 | /** @addtogroup STM32F4xx_StdPeriph_Driver 34 | * @{ 35 | */ 36 | 37 | /** @addtogroup PWR 38 | * @{ 39 | */ 40 | 41 | /* Exported types ------------------------------------------------------------*/ 42 | /* Exported constants --------------------------------------------------------*/ 43 | 44 | /** @defgroup PWR_Exported_Constants 45 | * @{ 46 | */ 47 | 48 | /** @defgroup PWR_PVD_detection_level 49 | * @{ 50 | */ 51 | #define PWR_PVDLevel_0 PWR_CR_PLS_LEV0 52 | #define PWR_PVDLevel_1 PWR_CR_PLS_LEV1 53 | #define PWR_PVDLevel_2 PWR_CR_PLS_LEV2 54 | #define PWR_PVDLevel_3 PWR_CR_PLS_LEV3 55 | #define PWR_PVDLevel_4 PWR_CR_PLS_LEV4 56 | #define PWR_PVDLevel_5 PWR_CR_PLS_LEV5 57 | #define PWR_PVDLevel_6 PWR_CR_PLS_LEV6 58 | #define PWR_PVDLevel_7 PWR_CR_PLS_LEV7 59 | 60 | #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLevel_0) || ((LEVEL) == PWR_PVDLevel_1)|| \ 61 | ((LEVEL) == PWR_PVDLevel_2) || ((LEVEL) == PWR_PVDLevel_3)|| \ 62 | ((LEVEL) == PWR_PVDLevel_4) || ((LEVEL) == PWR_PVDLevel_5)|| \ 63 | ((LEVEL) == PWR_PVDLevel_6) || ((LEVEL) == PWR_PVDLevel_7)) 64 | /** 65 | * @} 66 | */ 67 | 68 | 69 | /** @defgroup PWR_Regulator_state_in_STOP_mode 70 | * @{ 71 | */ 72 | #define PWR_MainRegulator_ON ((uint32_t)0x00000000) 73 | #define PWR_LowPowerRegulator_ON PWR_CR_LPDS 74 | 75 | /* --- PWR_Legacy ---*/ 76 | #define PWR_Regulator_ON PWR_MainRegulator_ON 77 | #define PWR_Regulator_LowPower PWR_LowPowerRegulator_ON 78 | 79 | #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MainRegulator_ON) || \ 80 | ((REGULATOR) == PWR_LowPowerRegulator_ON)) 81 | 82 | /** 83 | * @} 84 | */ 85 | 86 | /** @defgroup PWR_Regulator_state_in_UnderDrive_mode 87 | * @{ 88 | */ 89 | #define PWR_MainRegulator_UnderDrive_ON PWR_CR_MRUDS 90 | #define PWR_LowPowerRegulator_UnderDrive_ON ((uint32_t)(PWR_CR_LPDS | PWR_CR_LPUDS)) 91 | 92 | #define IS_PWR_REGULATOR_UNDERDRIVE(REGULATOR) (((REGULATOR) == PWR_MainRegulator_UnderDrive_ON) || \ 93 | ((REGULATOR) == PWR_LowPowerRegulator_UnderDrive_ON)) 94 | 95 | /** 96 | * @} 97 | */ 98 | #if defined(STM32F410xx) || defined(STM32F412xG) || defined(STM32F413_423xx) || defined(STM32F446xx) 99 | /** @defgroup PWR_Wake_Up_Pin 100 | * @{ 101 | */ 102 | #define PWR_WakeUp_Pin1 ((uint32_t)0x00) 103 | #define PWR_WakeUp_Pin2 ((uint32_t)0x01) 104 | #if defined(STM32F410xx) || defined(STM32F412xG) || defined(STM32F413_423xx) 105 | #define PWR_WakeUp_Pin3 ((uint32_t)0x02) 106 | #endif /* STM32F410xx || STM32F412xG || STM32F413_423xx */ 107 | 108 | #if defined(STM32F446xx) 109 | #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WakeUp_Pin1) || \ 110 | ((PIN) == PWR_WakeUp_Pin2)) 111 | #else /* STM32F410xx || STM32F412xG */ 112 | #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WakeUp_Pin1) || ((PIN) == PWR_WakeUp_Pin2) || \ 113 | ((PIN) == PWR_WakeUp_Pin3)) 114 | #endif /* STM32F446xx */ 115 | /** 116 | * @} 117 | */ 118 | #endif /* STM32F410xx || STM32F412xG || STM32F413_423xx || STM32F446xx */ 119 | 120 | /** @defgroup PWR_STOP_mode_entry 121 | * @{ 122 | */ 123 | #define PWR_STOPEntry_WFI ((uint8_t)0x01) 124 | #define PWR_STOPEntry_WFE ((uint8_t)0x02) 125 | #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPEntry_WFI) || ((ENTRY) == PWR_STOPEntry_WFE)) 126 | /** 127 | * @} 128 | */ 129 | 130 | /** @defgroup PWR_Regulator_Voltage_Scale 131 | * @{ 132 | */ 133 | #define PWR_Regulator_Voltage_Scale1 ((uint32_t)0x0000C000) 134 | #define PWR_Regulator_Voltage_Scale2 ((uint32_t)0x00008000) 135 | #define PWR_Regulator_Voltage_Scale3 ((uint32_t)0x00004000) 136 | #define IS_PWR_REGULATOR_VOLTAGE(VOLTAGE) (((VOLTAGE) == PWR_Regulator_Voltage_Scale1) || \ 137 | ((VOLTAGE) == PWR_Regulator_Voltage_Scale2) || \ 138 | ((VOLTAGE) == PWR_Regulator_Voltage_Scale3)) 139 | /** 140 | * @} 141 | */ 142 | 143 | /** @defgroup PWR_Flag 144 | * @{ 145 | */ 146 | #define PWR_FLAG_WU PWR_CSR_WUF 147 | #define PWR_FLAG_SB PWR_CSR_SBF 148 | #define PWR_FLAG_PVDO PWR_CSR_PVDO 149 | #define PWR_FLAG_BRR PWR_CSR_BRR 150 | #define PWR_FLAG_VOSRDY PWR_CSR_VOSRDY 151 | #define PWR_FLAG_ODRDY PWR_CSR_ODRDY 152 | #define PWR_FLAG_ODSWRDY PWR_CSR_ODSWRDY 153 | #define PWR_FLAG_UDRDY PWR_CSR_UDSWRDY 154 | 155 | /* --- FLAG Legacy ---*/ 156 | #define PWR_FLAG_REGRDY PWR_FLAG_VOSRDY 157 | 158 | #define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \ 159 | ((FLAG) == PWR_FLAG_PVDO) || ((FLAG) == PWR_FLAG_BRR) || \ 160 | ((FLAG) == PWR_FLAG_VOSRDY) || ((FLAG) == PWR_FLAG_ODRDY) || \ 161 | ((FLAG) == PWR_FLAG_ODSWRDY) || ((FLAG) == PWR_FLAG_UDRDY)) 162 | 163 | 164 | #define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \ 165 | ((FLAG) == PWR_FLAG_UDRDY)) 166 | 167 | /** 168 | * @} 169 | */ 170 | 171 | /** 172 | * @} 173 | */ 174 | 175 | /* Exported macro ------------------------------------------------------------*/ 176 | /* Exported functions --------------------------------------------------------*/ 177 | 178 | /* Function used to set the PWR configuration to the default reset state ******/ 179 | void PWR_DeInit(void); 180 | 181 | /* Backup Domain Access function **********************************************/ 182 | void PWR_BackupAccessCmd(FunctionalState NewState); 183 | 184 | /* PVD configuration functions ************************************************/ 185 | void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel); 186 | void PWR_PVDCmd(FunctionalState NewState); 187 | 188 | /* WakeUp pins configuration functions ****************************************/ 189 | #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx) || defined(STM32F411xE) 190 | void PWR_WakeUpPinCmd(FunctionalState NewState); 191 | #endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F401xx || STM32F411xE */ 192 | #if defined(STM32F410xx) || defined(STM32F412xG) || defined(STM32F413_423xx) ||defined(STM32F446xx) 193 | void PWR_WakeUpPinCmd(uint32_t PWR_WakeUpPinx, FunctionalState NewState); 194 | #endif /* STM32F410xx || STM32F412xG || STM32F413_423xx || STM32F446xx */ 195 | /* Main and Backup Regulators configuration functions *************************/ 196 | void PWR_BackupRegulatorCmd(FunctionalState NewState); 197 | void PWR_MainRegulatorModeConfig(uint32_t PWR_Regulator_Voltage); 198 | void PWR_OverDriveCmd(FunctionalState NewState); 199 | void PWR_OverDriveSWCmd(FunctionalState NewState); 200 | void PWR_UnderDriveCmd(FunctionalState NewState); 201 | 202 | #if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx) 203 | void PWR_MainRegulatorUnderDriveCmd(FunctionalState NewState); 204 | void PWR_LowRegulatorUnderDriveCmd(FunctionalState NewState); 205 | #endif /* STM32F427_437xx || STM32F429_439xx || STM32F446xx */ 206 | 207 | #if defined(STM32F401xx) || defined(STM32F410xx) || defined(STM32F411xE) || defined(STM32F412xG) || defined(STM32F413_423xx) 208 | void PWR_MainRegulatorLowVoltageCmd(FunctionalState NewState); 209 | void PWR_LowRegulatorLowVoltageCmd(FunctionalState NewState); 210 | #endif /* STM32F401xx || STM32F410xx || STM32F411xE || STM32F412xG || STM32F413_423xx */ 211 | 212 | /* FLASH Power Down configuration functions ***********************************/ 213 | void PWR_FlashPowerDownCmd(FunctionalState NewState); 214 | 215 | /* Low Power modes configuration functions ************************************/ 216 | void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry); 217 | void PWR_EnterUnderDriveSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry); 218 | void PWR_EnterSTANDBYMode(void); 219 | 220 | /* Flags management functions *************************************************/ 221 | FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG); 222 | void PWR_ClearFlag(uint32_t PWR_FLAG); 223 | 224 | #ifdef __cplusplus 225 | } 226 | #endif 227 | 228 | #endif /* __STM32F4xx_PWR_H */ 229 | 230 | /** 231 | * @} 232 | */ 233 | 234 | /** 235 | * @} 236 | */ 237 | 238 | --------------------------------------------------------------------------------