This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nRF52 Software Serial library similar to Arduino software serial

I have made a software serial library for nRF52840 similar to Arduino software serial. It is working fine. nRF52840 has two UARTE instance and one UART instance, As for my application requirement I need 3 UART or UARTE instances. 

Working baud rates: 1200, 2400, 4800, 9600, 14400, 19200, 28800, 31250, 38400, 56000, 57600, 76800,

Not working rates : 115200 

Count  of UART instances:  4. You can increase the number of instances by doing some minor modification in the software.

Test: I have only tested one SF_UART. It is working fine.

Can you help me to improve this library? I want to use 115200 baud rate, which is not working yet. 

All community members can use this library if they are lacking hardware UART. Please help me to improve it more. keep sharing more updates.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//#include "includes.h"
#include <stdint.h>
#include "gpio.h"
#include "sf_uart.h"
void (*sf_uart0_appRxEventHandler)(uint16_t rx);
void (*sf_uart1_appRxEventHandler)(uint16_t rx);
void (*sf_uart2_appRxEventHandler)(uint16_t rx);
void (*sf_uart3_appRxEventHandler)(uint16_t rx);
sf_uart_config sf_uart0_config =
{
.rxPin = SF_RX0_PIN_NUMBER,
.txPin = SF_TX0_PIN_NUMBER,
.baudrate = 9600,
.delay =
{
.rx_centering = 0,
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sf_uart.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//#include "includes.h"
#include <stdint.h>
#include "nrf_drv_gpiote.h"
#include "gpio.h"
void (*gpiote0_appInEventHandler)();
void (*gpiote1_appInEventHandler)();
void (*gpiote2_appInEventHandler)();
void (*gpiote3_appInEventHandler)();
void (*gpiote4_appInEventHandler)();
void (*gpiote5_appInEventHandler)();
void (*gpiote6_appInEventHandler)();
void (*gpiote7_appInEventHandler)();
void (*gpiote8_appInEventHandler)();
void (*gpiote9_appInEventHandler)();
void (*gpiote10_appInEventHandler)();
void (*gpiote11_appInEventHandler)();
void (*gpiote12_appInEventHandler)();
void (*gpiote13_appInEventHandler)();
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
gpio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdint.h>
#include <string.h>
#include "nrf_delay.h"
#include "sf_uart.h"
char rxBuffer[100] = {0};
uint8_t rxCount = 0;
void event_handler(uint16_t rx)
{
rxBuffer[rxCount++] = rx;
if(rxCount == 100)
{
rxCount = 0;
memset(rxBuffer, 0, 100);
}
}
int main()
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX