diff --git a/.config b/.config index 434716a..c0e4b1a 100644 --- a/.config +++ b/.config @@ -1577,7 +1577,13 @@ CONFIG_SOC_SERIES_STM32F4=y # CONFIG_BSP_USING_ARDUINO is not set CONFIG_BSP_USING_USB_TO_USART=y # CONFIG_BSP_USING_COM3 is not set -# CONFIG_BSP_USING_RS485 is not set +CONFIG_BSP_USING_RS485=y + +# +# set rts pin number +# +CONFIG_BSP_RS485_RTS_PIN=104 +CONFIG_RS485_UART_DEVICE_NAME="uart6" CONFIG_BSP_USING_SRAM=y CONFIG_BSP_USING_ONBOARD_LCD=y CONFIG_BSP_USING_ONBOARD_LCD_PWM_BL=y @@ -1614,12 +1620,16 @@ CONFIG_BSP_USING_UART1=y # CONFIG_BSP_USING_UART3 is not set # CONFIG_BSP_USING_UART4 is not set # CONFIG_BSP_USING_UART5 is not set -# CONFIG_BSP_USING_UART6 is not set +CONFIG_BSP_USING_UART6=y +# CONFIG_BSP_UART6_RX_USING_DMA is not set +# CONFIG_BSP_UART6_TX_USING_DMA is not set # CONFIG_BSP_USING_TIM is not set CONFIG_BSP_USING_PWM=y # CONFIG_BSP_USING_PWM1 is not set # CONFIG_BSP_USING_PWM2 is not set -# CONFIG_BSP_USING_PWM3 is not set +CONFIG_BSP_USING_PWM3=y +CONFIG_BSP_USING_PWM3_CH2=y +# CONFIG_BSP_USING_PWM3_CH4 is not set # CONFIG_BSP_USING_PWM4 is not set CONFIG_BSP_USING_PWM14=y CONFIG_BSP_USING_PWM14_CH1=y diff --git a/applications/main.c b/applications/main.c index 4664a02..7cbb63d 100644 --- a/applications/main.c +++ b/applications/main.c @@ -12,13 +12,13 @@ #include #include #include "drv_common.h" - +#include #define DBG_TAG "main" #define DBG_LVL DBG_LOG #include #include -#include + /* 配置 LED 灯引脚 */ #define PIN_LED_B GET_PIN(F, 11) // PF11 : LED_B --> LED @@ -26,9 +26,9 @@ #define LCD_MAX 240 int roundxy[4][2] = { - {0, 0}, + {0, 16}, {0, LCD_MAX}, - {LCD_MAX, 0}, + {LCD_MAX, 16}, {LCD_MAX, LCD_MAX}, }; int xymove[4][2] = { @@ -40,21 +40,33 @@ int xymove[4][2] = { extern void wlan_autoconnect_init(void); +void mytime() +{ + rt_thread_mdelay(10000); + time_t cur_time; + + cur_time = ntp_get_time(RT_NULL); + if( cur_time) + { + rt_kprintf("NTP Server Time: %s", ctime((const time_t *)&cur_time)); + } + lcd_show_string(2, 2, 16, ctime((const time_t *)&cur_time)); +} void lcd_black(int x, int y) { lcd_address_set(x, y, x, y); lcd_write_half_word(BLACK); } -void xy_round(int x, int y, int x2, int y2, int r,int ii) +void xy_round(int x, int y, int x2, int y2, int r, int ii) { - rt_kprintf("x:%d,y:%d,x2:%d,y2:%d,r:%d\n", x, y, x2, y2, r); - for (int i = x; i != x2; i+=xymove[ii][0]) + // rt_kprintf("x:%d,y:%d,x2:%d,y2:%d,r:%d\n", x, y, x2, y2, r); + for (int i = x; i != x2; i += xymove[ii][0]) { - for (int j = y; j != y2; j+=xymove[ii][1]) + for (int j = y; j != y2; j += xymove[ii][1]) { int newi = x2 - i; int newj = y2 - j; - rt_kprintf("(%d,%d,%d)",(newi * newi + newj * newj), newi, newj); + // rt_kprintf("(%d,%d,%d)",(newi * newi + newj * newj), newi, newj); if ((newi * newi + newj * newj) > (r * r)) { // rt_kprintf("x:%d,y:%d\n", i, j); @@ -65,9 +77,12 @@ void xy_round(int x, int y, int x2, int y2, int r,int ii) } void my_round(int r) { + lcd_fill(0, 0, roundxy[2][0], roundxy[2][1],BLACK); + lcd_write_half_word(BLACK); + for (int i = 0; i < 4; i++) { - xy_round(roundxy[i][0], roundxy[i][1], roundxy[i][0] + r * xymove[i][0], roundxy[i][1] + r * xymove[i][1], r,i); + xy_round(roundxy[i][0], roundxy[i][1], roundxy[i][0] + r * xymove[i][0], roundxy[i][1] + r * xymove[i][1], r, i); } } void xy_sink() @@ -82,14 +97,19 @@ void xy_sink() // rt_kprintf("(%d,...) Blacked\n", i); } } +// void mylvgl() +// { +// lv_init(); +// lv_demo_music(); +// } int main(void) { char str[] = "wifi join Dong abcd07691234"; my_round(20); - rt_wlan_config_autoreconnect(RT_TRUE); rt_wlan_connect("Dong", "abcd07691234"); system(str); + mytime(); /* init Wi-Fi auto connect feature */ // wlan_autoconnect_init(); diff --git a/rtconfig.h b/rtconfig.h index d01ec82..76b2e0f 100644 --- a/rtconfig.h +++ b/rtconfig.h @@ -578,6 +578,12 @@ /* Onboard Peripheral Drivers */ #define BSP_USING_USB_TO_USART +#define BSP_USING_RS485 + +/* set rts pin number */ + +#define BSP_RS485_RTS_PIN 104 +#define RS485_UART_DEVICE_NAME "uart6" #define BSP_USING_SRAM #define BSP_USING_ONBOARD_LCD #define BSP_USING_ONBOARD_LCD_PWM_BL @@ -597,7 +603,10 @@ #define BSP_USING_GPIO #define BSP_USING_UART #define BSP_USING_UART1 +#define BSP_USING_UART6 #define BSP_USING_PWM +#define BSP_USING_PWM3 +#define BSP_USING_PWM3_CH2 #define BSP_USING_PWM14 #define BSP_USING_PWM14_CH1 #define BSP_USING_ON_CHIP_FLASH