Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work on serial #585

Merged
merged 2 commits into from
Jan 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
///////////

// pin configuration for UART1
// port: GPIOA
// port for TX pin is: GPIOA
// port for RX pin is: GPIOA
// TX pin: is GPIOA_9
// RX pin: is GPIOA_10
// GPIO alternate pin function is 7 (see "Table 12. STM32F427xx and STM32F429xx alternate function mapping" in STM32F427xx and STM32F429xx datasheet)
UART_CONFIG_PINS(1, GPIOA, 9, 10, 7)
UART_CONFIG_PINS(1, GPIOA, GPIOA, 9, 10, 7)

// buffers size
// tx buffer size: 256 bytes
Expand Down Expand Up @@ -46,11 +47,12 @@ UART_UNINIT(1)
///////////

// pin configuration for UART2
// port: GPIOD
// port for TX pin is: GPIOD
// port for RX pin is: GPIOD
// TX pin: is GPIOD_5
// RX pin: is GPIOD_6
// GPIO alternate pin function is 7 (see "Table 12. STM32F427xx and STM32F429xx alternate function mapping" in STM32F427xx and STM32F429xx datasheet)
UART_CONFIG_PINS(2, GPIOD, 5, 6, 7)
UART_CONFIG_PINS(2, GPIOD, GPIOD, 5, 6, 7)

// buffers size
// tx buffer size: 256 bytes
Expand Down Expand Up @@ -82,11 +84,12 @@ UART_UNINIT(2)
///////////

// pin configuration for UART3
// port: GPIOD
// port for TX pin is: GPIOD
// port for RX pin is: GPIOD
// TX pin: is GPIOD_8
// RX pin: is GPIOD_9
// GPIO alternate pin function is 7 (see "Table 12. STM32F427xx and STM32F429xx alternate function mapping" in STM32F427xx and STM32F429xx datasheet)
UART_CONFIG_PINS(3, GPIOD, 8, 9, 7)
UART_CONFIG_PINS(3, GPIOD, GPIOD, 8, 9, 7)

// buffers size
// tx buffer size: 256 bytes
Expand Down Expand Up @@ -118,11 +121,12 @@ UART_UNINIT(3)
///////////

// pin configuration for UART6
// port: GPIOC
// port for TX pin is: GPIOC
// port for RX pin is: GPIOC
// TX pin: is GPIOC_6
// RX pin: is GPIOC_7
// GPIO alternate pin function is 8 (see "Table 12. STM32F427xx and STM32F429xx alternate function mapping" in STM32F427xx and STM32F429xx datasheet)
UART_CONFIG_PINS(6, GPIOC, 6, 7, 8)
UART_CONFIG_PINS(6, GPIOC, GPIOC, 6, 7, 8)

// buffers size
// tx buffer size: 256 bytes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
///////////

// pin configuration for UART3
// port: GPIOD
// port for TX pin is: GPIOD
// port for RX pin is: GPIOD
// TX pin: is GPIOD_8
// RX pin: is GPIOD_9
// GPIO alternate pin function is 7 (see "Table 12. STM32F427xx and STM32F429xx alternate function mapping" in STM32F427xx and STM32F429xx datasheet)
UART_CONFIG_PINS(3, GPIOD, 8, 9, 7)
UART_CONFIG_PINS(3, GPIOD, GPIOD, 8, 9, 7)

// buffers size
// tx buffer size: 256 bytes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
///////////

// pin configuration for UART2
// port: GPIOD
// port for TX pin is: GPIOD
// port for RX pin is: GPIOD
// TX pin: is GPIOD_5
// RX pin: is GPIOD_6
// GPIO alternate pin function is 7 (see "Table 12. STM32F427xx and STM32F429xx alternate function mapping" in STM32F427xx and STM32F429xx datasheet)
UART_CONFIG_PINS(2, GPIOD, 5, 6, 7)
UART_CONFIG_PINS(2, GPIOD, GPIOD, 5, 6, 7)

// buffers size
// tx buffer size: 256 bytes
Expand Down Expand Up @@ -46,11 +47,12 @@ UART_UNINIT(2)
///////////

// pin configuration for UART6
// port: GPIOC
// port for TX pin is: GPIOC
// port for RX pin is: GPIOC
// TX pin: is GPIOC_6
// RX pin: is GPIOC_7
// GPIO alternate pin function is 8 (see "Table 12. STM32F427xx and STM32F429xx alternate function mapping" in STM32F427xx and STM32F429xx datasheet)
UART_CONFIG_PINS(6, GPIOC, 6, 7, 8)
UART_CONFIG_PINS(6, GPIOC, GPIOC, 6, 7, 8)

// buffers size
// tx buffer size: 256 bytes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
///////////

// pin configuration for UART1
// port: GPIOA
// port for TX pin is: GPIOA
// port for RX pin is: GPIOA
// TX pin: is GPIOA_9
// RX pin: is GPIOA_10
// GPIO alternate pin function is 7 (see "Table 12. STM32F427xx and STM32F429xx alternate function mapping" in STM32F427xx and STM32F429xx datasheet)
UART_CONFIG_PINS(1, GPIOA, 9, 10, 7)
UART_CONFIG_PINS(1, GPIOA, GPIOA, 9, 10, 7)

// buffers size
// tx buffer size: 256 bytes
Expand Down Expand Up @@ -46,11 +47,12 @@ UART_UNINIT(1)
///////////

// pin configuration for UART3
// port: GPIOD
// port for TX pin is: GPIOD
// port for RX pin is: GPIOD
// TX pin: is GPIOD_8
// RX pin: is GPIOD_9
// GPIO alternate pin function is 7 (see "Table 12. STM32F427xx and STM32F429xx alternate function mapping" in STM32F427xx and STM32F429xx datasheet)
UART_CONFIG_PINS(3, GPIOD, 8, 9, 7)
UART_CONFIG_PINS(3, GPIOD, GPIOD, 8, 9, 7)

// buffers size
// tx buffer size: 256 bytes
Expand Down Expand Up @@ -82,11 +84,12 @@ UART_UNINIT(3)
///////////

// pin configuration for UART6
// port: GPIOC
// port for TX pin is: GPIOC
// port for RX pin is: GPIOC
// TX pin: is GPIOC_6
// RX pin: is GPIOC_7
// GPIO alternate pin function is 8 (see "Table 12. STM32F427xx and STM32F429xx alternate function mapping" in STM32F427xx and STM32F429xx datasheet)
UART_CONFIG_PINS(6, GPIOC, 6, 7, 8)
UART_CONFIG_PINS(6, GPIOC, GPIOC, 6, 7, 8)

// buffers size
// tx buffer size: 256 bytes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
///////////

// pin configuration for UART6
// port: GPIOC
// port for TX pin is: GPIOC
// port for RX pin is: GPIOC
// TX pin: is GPIOC_6
// RX pin: is GPIOC_7
// GPIO alternate pin function is 8 (see "Table 13. STM32F765xx, STM32F767xx, STM32F768Ax and STM32F769xx alternate function mapping" in STM32F769I datasheet)
UART_CONFIG_PINS(6, GPIOC, 6, 7, 8)
UART_CONFIG_PINS(6, GPIOC, GPIOC, 6, 7, 8)

// buffers size
// tx buffer size: 256 bytes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ struct NF_PAL_UART
// the following macro defines a function that configures the GPIO pins for a STM32 UART/USART
// it gets called in the Windows_Devices_SerialCommunication_SerialDevice::NativeConfig function
// this is required because the UART/USART peripherals can use multiple GPIO configuration combinations
#define UART_CONFIG_PINS(num, gpio_port, tx_pin, rx_pin, alternate_function) void ConfigPins_UART##num() { \
palSetPadMode(gpio_port, tx_pin, PAL_MODE_ALTERNATE(alternate_function)); \
palSetPadMode(gpio_port, rx_pin, PAL_MODE_ALTERNATE(alternate_function)); \
#define UART_CONFIG_PINS(num, gpio_port_tx, gpio_port_rx, tx_pin, rx_pin, alternate_function) void ConfigPins_UART##num() { \
palSetPadMode(gpio_port_tx, tx_pin, PAL_MODE_ALTERNATE(alternate_function)); \
palSetPadMode(gpio_port_rx, rx_pin, PAL_MODE_ALTERNATE(alternate_function)); \
}

///////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ static void RxChar(UARTDriver *uartp, uint16_t c)
palUart->RxRingBuffer.Push((uint8_t)c);

// check if the requested bytes are available in the buffer
if(palUart->RxRingBuffer.Length() >= palUart->RxBytesToRead)
if(palUart->RxBytesToRead > 0 && palUart->RxRingBuffer.Length() >= palUart->RxBytesToRead)
{
// reset Rx bytes to read count
palUart->RxBytesToRead = 0;
Expand Down