STM32F4Uart

Alexander Shiryaev, 2016.09, 2017.04, 2019.10, 2020.12 Modified by Tenko for use with ECS

RM0090, Reference manual,

STM32F4{0,1}{5,7}xx, STM32F4{2,3}{7,9}xx (U1..U8)

RM0383, Reference manual,

STM32F411x{C,E} (U1,U2,U6)

RM0390, Reference manual,

STM32F446xx (U1..U6)

Const

parityNone* = 0;
parityEven* = 8 + 2;
parityOdd* = 8 + 3;
stopBits1* = 0;
stopBits05* = 1;
stopBits2* = 2;
stopBits15* = 3;

Types

InitPar* = RECORD
        RXPinPort*, RXPinN*, RXPinAF*: INTEGER;
        TXPinPort*, TXPinN*, TXPinAF*: INTEGER;
        UCLK*: INTEGER;
        baud*: INTEGER;
        parity*: INTEGER;
        stopBits*: INTEGER;
        disableReceiver*: BOOLEAN
    END;
Bus* = RECORD (BusUart.Bus)
        inBuffer : InBuffer.RingBuffer;
        outBuffer : OutBuffer.RingBuffer;
        enableTCI, disableTCI: SET;
        SR, DR, CR1: ADDRESS;
    END;

Procedures

Init

Initialize U[s]art[n] bus

PROCEDURE Init* (VAR b : Bus; par-: InitPar);

Bus.Any

Return number of characters available in read buffer

PROCEDURE (VAR this : Bus) Any*(): LENGTH;

Bus.TXDone

Return TRUE if we are not currently transmitting data

PROCEDURE (VAR this : Bus) TXDone*(): BOOLEAN;

Bus.ReadBytes

Read bytes into buffer with start and length.

PROCEDURE (VAR this: Bus) ReadBytes*(VAR buffer : ARRAY OF BYTE; start, length : LENGTH): LENGTH;

Bus.ReadChar

Read CHAR value. Return TRUE if success.

PROCEDURE (VAR this: Bus) ReadChar*(VAR value : CHAR): BOOLEAN;

Bus.WriteBytes

Write bytes from buffer with start and length.

PROCEDURE (VAR this: Bus) WriteBytes*(VAR buffer : ARRAY OF BYTE; start, length: LENGTH): LENGTH;

Bus.WriteChar

Write CHAR value. Return TRUE if success.

PROCEDURE (VAR this: Bus) WriteChar*(value : CHAR): BOOLEAN;