-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuart.h
More file actions
69 lines (53 loc) · 2.03 KB
/
uart.h
File metadata and controls
69 lines (53 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef _UART_
#define _UART_
#include "gpio.h"
#include <stdint.h>
#include <stdio.h>
#define UART ((NRF_UART_REG*)0x40002000)
/*Table 275 nRF51_RM*/
/*0x000 offset*/
typedef struct{
/*Tasks*/
volatile uint32_t STARTRX; //Start UART reciever
volatile uint32_t STOPRX; //Stop UART reciever
volatile uint32_t STARTTX; //Start UART transmitter
volatile uint32_t STOPTX; //Stop UART transmitter
volatile uint32_t RESERVED[3];
volatile uint32_t SUSPEND; //Suspend UART
volatile uint32_t RESERVED1[56];
/*Events*/
volatile uint32_t CTS; //CTS is activated (set low). Clear to send
volatile uint32_t NCTS; //CTS is deactivated (set high). Not clear to send
volatile uint32_t RXDRDY; //Data recieved in RXD
volatile uint32_t RESERVED2[4];
volatile uint32_t TXDRDY; //Data sendt from TXD
volatile uint32_t RESERVED3[1];
volatile uint32_t ERROR; //Error detected
volatile uint32_t RESERVED4[7];
volatile uint32_t RXTO; //Reciever timeout
volatile uint32_t RESERVED5[110];
/*Registers*/
volatile uint32_t INTEN; //Enable or disable interrupt
volatile uint32_t INTENSET; //Enable interrupt
volatile uint32_t INTENCLR; //Disable interrupt
volatile uint32_t RESERVED6[93];
volatile uint32_t ERRORSCR; //Error source
volatile uint32_t RESERVED7[31];
volatile uint32_t ENABLE; //Enable UART
volatile uint32_t RESERVED8[1];
volatile uint32_t PSELRTS; //Pin select for RTS
volatile uint32_t PSELTXD; //Pin select for TXD
volatile uint32_t PSELCTS; //Pin select for CTS
volatile uint32_t PSELRXD; //Pin select for RXD
volatile uint32_t RXD; //RXD register
volatile uint32_t TXD; //TXD register
volatile uint32_t RESERVED9[1];
volatile uint32_t BAUDRATE; //Baud rate
volatile uint32_t RESERVED10[17];
volatile uint32_t CONFIG; //Configuration of parity and hardware flow control
}NRF_UART_REG;
void uart_init();
void uart_send(char letter);
char uart_read();
ssize_t _write(int fd , const void *buf, size_t count);
#endif