MBSP

Microcontroller Board Support Package

User Tools

Site Tools


uart_group

UART group

This group defines all used Universal Asynchronous Receiver Transmitter (UART) interfaces.

Each UART is a sub group with the UART name as the group name.

    "UART": {
        "debug_uart": {
            "pad_tx": "PA5",
            "pad_rx": "PA6",
            "pad_cts": "PA7",
            "pad_rts": "PA15",
            "bits_per_packet": "8",
            "parity": "None",
            "stop_bits": "1",
            "baud_rate": "115200",
            "hardware_flow_control": "no",
            "receive_buffer_size": "100",
            "send_buffer_size": "500",
            "peripheral" : "UART0",
            "IRQ" : "20", 
            "IRQ_priority" : "0",
        }
    }

pad_tx

The UART will send data on this pin. (Idle = High). Either this or the pad_rx must be given.

pad_rx

The UART will receive (read) signals on this pin. Either this or pad_rx must be given.

pad_cts

Clear to send signal for flow control. Will not be used if not defined.

pad_rts

Request to Send signal for flow control. Will not be used if not defined.

bits_per_packet

defines the number of data bits. Possible values are:

  • 7
  • 8
  • 9

type: enum

default: 8

parity

defines the parity bit. Possible values are:

  • None : no parity bit used.
  • Odd : the parity bits value makes sure that the packet contains an odd number of bits with value “1”.
  • Even : the parity bits value makes sure that the packet contains an even number of bits with value “1”.

type: enum

default: None

stop_bits

defines the number of stop bits. Possible values are:

  • 1
  • 1,5
  • 2

type: enum

default: 8

baud_rate

defines the number of bits send per second.

type: int

default: 115200

hardware_flow_control

defines if the Request to Send (RTS) and Clear to send (CTS) signals should be used for flow control. Possible values are:

  • off (RTS and CTS pins are not used.
  • RTS only
  • CTS only
  • on (RTS and CTS signals are used)

type: enum

default: off

receive_buffer_size

defines the number of bytes in the receive buffer of the driver.

type: int

default: 100

send_buffer_size

defines the number of bytes in the send buffer of the driver.

type: int

default: 500

peripheral

name of the UART peripheral to use.

type: String

IRQ

The interrupt number of the peripheral.

type: int

IRQ_priority

The interrupt priority of the interrupt.

type: int

API

The part “signal_name” in the described functions will be replaced by the name of the signal. E.g. if your signal is called “debug_uart” then the API function “signal_name_send_bytes” will become “debug_uart_send_bytes”.

send

void signal_name_send_bytes(const uint8_t *data, const uint32_t length)

Will send “length” bytes from the buffer “data” out on the TX line of the UART.

void signal_name_send_String(char* str)

Will send out the bytes of the sting on the TX line of the UART.

void signal_name_putc(void* p, char c)

Will send out the byte “c” on the TX line of the UART. The pointer “p” will not be used. This function is provided to be compatible with printf().

receive

uint32_t signal_name_get_num_received_bytes(void)

Returns the number of bytes that have been received on the RX line of the UART and have not been read.

uint8_t signal_name_get_next_received_byte(void)

Returns the next byte that has been received on the RX line of the UART.

bool signal_name_get_received_bytes(uint8_t *buf, const uint32_t length)

copies the “length” received bytes into the buffer “buf”. If less than “length” bytes have been received then this function returns false.

uart_group.txt · Last modified: by lars