I've been trying to get communicate over serial to my STM32F446RE Nucleo board. I was struggling with getting sdWrite/Put/Read/Get when I decided to try chprintf(). I'm guessing that I'm overlooking something basic and would appreciate an extra set of eyes.
I'm using the nucleo's built-in ST-Link v2-1 and monitoring the serial with "cat /dev/ttyACM0" after configuring the device with stty. The code below works for as expected for chprintf, but I get no response when I switch to sdWrite:
Code: Select all
#include "ch.h"
#include "hal.h"
#include "chprintf.h"
/* Serial configuration. */
static const SerialConfig myserialcfg = {
115200,
0,
USART_CR2_STOP1_BITS,
0
};
/* Dummy LED blinker thread. */
static THD_WORKING_AREA(waThdBlinker, 128);
static THD_FUNCTION(ThdBlinker, arg) {
(void) arg;
chRegSetThreadName("Blinker");
while(true) {
palToggleLine(LINE_LED_GREEN);
chThdSleepMilliseconds(500);
}
}
/* Application entry point. */
int main(void) {
/* ChibiOS/HAL and ChibiOS/RT initialization. */
halInit();
chSysInit();
/* Creating a dummy blinker thread. */
chThdCreateStatic(waThdBlinker, sizeof(waThdBlinker), NORMALPRIO, ThdBlinker,
NULL);
/* Enabling event on falling edge of PC13 signal.*/
palEnablePadEvent(GPIOC, 13U, PAL_EVENT_MODE_FALLING_EDGE);
/* Starting Serial Driver 2 with our configuration. */
sdStart(&SD2, NULL);
/* main() thread loop. */
while (true) {
/* Waiting for a falling edge.*/
palWaitPadTimeout(GPIOC, 13U, TIME_INFINITE);
/* Printing a string over USART2 using Serial driver.*/
// sdWrite(&SD2, (uint8_t*)"Test\r\n", 6);
chprintf((BaseSequentialStream*)&SD2, "Test");
}
}From halconf.h:
Code: Select all
#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
#define HAL_USE_SERIAL TRUE
#endif
mcuconf.h:
Code: Select all
/*
* SERIAL driver system settings.
*/
#define STM32_SERIAL_USE_USART1 FALSE
#define STM32_SERIAL_USE_USART2 TRUE
#define STM32_SERIAL_USE_USART3 FALSE
#define STM32_SERIAL_USE_UART4 FALSE
#define STM32_SERIAL_USE_UART5 FALSE
#define STM32_SERIAL_USE_USART6 FALSE
#define STM32_SERIAL_USE_UART7 FALSE
#define STM32_SERIAL_USE_UART8 FALSE
#define STM32_SERIAL_USART1_PRIORITY 12
#define STM32_SERIAL_USART2_PRIORITY 12
#define STM32_SERIAL_USART3_PRIORITY 12
#define STM32_SERIAL_UART4_PRIORITY 12
#define STM32_SERIAL_UART5_PRIORITY 12
#define STM32_SERIAL_USART6_PRIORITY 12
#define STM32_SERIAL_UART7_PRIORITY 12
#define STM32_SERIAL_UART8_PRIORITY 12
Any help would be appreciated.
