Elevator v2.0
Elevator Documenation
Loading...
Searching...
No Matches
serial_communication.h
Go to the documentation of this file.
1
11#ifndef _SERIAL_COMMUNICATION_H_
12#define _SERIAL_COMMUNICATION_H_
13
14#include <stdio.h>
15#include "freertos/FreeRTOS.h"
16#include "freertos/task.h"
17#include "driver/uart.h"
18#include <string.h>
19
20// UART 0 Pins
21#define UART_0_RX 3
22#define UART_0_TX 1
23
24// UART 1 Pins
25#define UART_1_RX 9
26#define UART_1_TX 10
27
28// UART 2 Pins
29#define UART_2_TX 17
30#define UART_2_RX 16
31
32// UART Buffer size
33#define UART_BUFFER_SIZE 1024
34
35// UARTs selection
36#define UART_0 UART_NUM_0
37#define UART_1 UART_NUM_1
38#define UART_2 UART_NUM_2
39
40// No pin selection
41#define NO_PIN UART_PIN_NO_CHANGE
42
43#define FIVE_BITS UART_DATA_5_BITS
44#define SIX_BITS UART_DATA_6_BITS
45#define SEVEN_BITS UART_DATA_7_BITS
46#define EIGHT_BITS UART_DATA_8_BITS
47
48#define ONE_STOP_BIT UART_STOP_BITS_1
49#define ONE_HALF_STOP_BIT UART_STOP_BITS_1_5
50#define TWO_STOP_BIT UART_STOP_BITS_2
51
72typedef struct SerialComm
73{
74 int gpio_rx;
75 int gpio_tx;
78 uart_port_t uart_num;
79 uint32_t baud_rate;
80 uart_parity_t parity;
81 uart_stop_bits_t stop_bits;
82 uart_word_length_t data_bits;
84
91void serialCommInit(SerialComm *serial);
92
100void serial_write(SerialComm *serial, char *str, int size);
101
102#endif
void serial_write(SerialComm *serial, char *str, int size)
serial_write will write the bytes that will be sent via serial communication
Definition: serial_communication.c:55
void serialCommInit(SerialComm *serial)
serialCommInit will intialize external serial communication
Definition: serial_communication.c:32
Custom SerialComm structure for UART adaptablity.
Definition: serial_communication.h:73
int gpio_rts
Definition: serial_communication.h:76
uart_parity_t parity
Definition: serial_communication.h:80
uart_word_length_t data_bits
Definition: serial_communication.h:82
uint32_t baud_rate
Definition: serial_communication.h:79
uart_stop_bits_t stop_bits
Definition: serial_communication.h:81
int gpio_rx
Definition: serial_communication.h:74
int gpio_tx
Definition: serial_communication.h:75
int gpio_cts
Definition: serial_communication.h:77
uart_port_t uart_num
Definition: serial_communication.h:78