diff --git a/CMakeLists.txt b/CMakeLists.txt index 18d7cfc..2175ec2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ add_compile_options(-mcpu=${MCPU} -mthumb -mthumb-interwork) add_compile_options(-ffunction-sections -fdata-sections -fno-common -fmessage-length=0) add_definitions(-DSTM32F439xx) -add_compile_definitions(HSE_VALUE=8000000) +add_definitions(-DHSE_VALUE=8000000) include_directories( ${PROJECT_SOURCE_DIR}/bsp @@ -46,6 +46,8 @@ file(GLOB_RECURSE SOURCES set(LINKER_SCRIPT ${PROJECT_SOURCE_DIR}/stm32_flash.ld) add_link_options(-specs=nosys.specs) +add_link_options(-specs=nano.specs) +add_link_options(-u _printf_float) add_link_options(-Wl,-gc-sections,--print-memory-usage,-Map=${PROJECT_BINARY_DIR}/${PROJECT_NAME}.map) add_link_options(-mcpu=${MCPU} -mthumb -mthumb-interwork) add_link_options(-T ${LINKER_SCRIPT}) diff --git a/app/app.c b/app/app.c index 5383e48..017911b 100644 --- a/app/app.c +++ b/app/app.c @@ -16,17 +16,8 @@ void loop() { } void app() { - volatile uint8_t sendData[8]; - volatile uint8_t bytesToSend = 8; - // Счетчик отправленных байт - volatile uint8_t sendDataCounter = 0; - for (uint8_t i = 0; i < 8; i++) - { - sendData[i] = i; - } - // USART_ITConfig(USART2, USART_IT_TC, ENABLE); while(1) { - USART_SendData(USART2, sendData[sendDataCounter++ % 8]); + printf("Hello, world%.6f\r\n", 5.432); loop(); }; } diff --git a/bsp/bsp.c b/bsp/bsp.c index 4b53e32..f8653e6 100644 --- a/bsp/bsp.c +++ b/bsp/bsp.c @@ -10,6 +10,36 @@ /* USB OTG FS, SDIO and RNG Clock = PLL_VCO / PLLQ */ #define PLL_Q 7 +// #ifdef __GNUC__ +// #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) +// #else +// #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) +// #endif /* __GNUC__ */ + +// PUTCHAR_PROTOTYPE +// { +// for(uint8_t i = 0; i < len; ++i) { +// USART_SendData(USART2, ptr[i]); +// } +// return ch; +// } + +int _write(int fd, char* ptr, int len) { + int i= 0; + while(i < len) { + while (USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET); // Ждем, пока буфер передатчика не освободится + USART_SendData(USART2, *ptr++); // Отправляем символ + i++; + } + + return len; +} + +void UART_SendString(const char* str) { + while (*str) { + + } +} diff --git a/bsp/bsp.h b/bsp/bsp.h index 5bbfbca..c2e5df6 100644 --- a/bsp/bsp.h +++ b/bsp/bsp.h @@ -5,6 +5,7 @@ #include "stm32f4xx_gpio.h" #include "stm32f4xx_rcc.h" #include "stm32f4xx_usart.h" +#include void board_init();