Contiki-Inga 3.x
Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
cpu
cc2430
dev
uart0.c
Go to the documentation of this file.
1
/**
2
* \file
3
*
4
* uart0 write routines
5
*
6
* \author
7
*
8
* Anthony "Asterisk" Ambuehl
9
*
10
*/
11
#include <stdlib.h>
12
#include <string.h>
13
14
#include "
cc2430_sfr.h
"
15
#include "dev/uart0.h"
16
17
#if UART_ZERO_ENABLE
18
/*---------------------------------------------------------------------------*/
19
void
20
uart0_init()
21
{
22
UART_SET_SPEED(0, UART_115_M, UART_115_E);
23
24
#ifdef UART0_ALTERNATIVE_2
25
PERCFG |= U0CFG;
/*alternative port 2 = P1.5-2*/
26
#ifdef UART0_RTSCTS
27
P1SEL |= 0x3C;
/*peripheral select for TX and RX, RTS, CTS*/
28
#else
29
P1SEL |= 0x30;
/*peripheral select for TX and RX*/
30
P1 &= ~0x08;
/*RTS down*/
31
#endif
32
P1DIR |= 0x28;
/*RTS, TX out*/
33
P1DIR &= ~0x14;
/*CTS & RX in*/
34
#else
35
PERCFG &= ~U0CFG;
/*alternative port 1 = P0.5-2*/
36
#ifdef UART0_RTSCTS
37
P0SEL |= 0x3C;
/*peripheral select for TX and RX, RTS, CTS*/
38
#else
39
P0SEL |= 0x0C;
/*peripheral select for TX and RX*/
40
P0 &= ~0x20;
/*RTS down*/
41
#endif
42
P0DIR |= 0x28;
/*RTS & TX out*/
43
P0DIR &= ~0x14;
/*CTS & RX in*/
44
#endif
45
46
47
#ifdef UART0_RTSCTS
48
U0UCR = 0x42;
/*defaults: 8N1, RTS/CTS, high stop bit*/
49
#else
50
U0UCR = 0x02;
/*defaults: 8N1, no flow control, high stop bit*/
51
#endif
52
53
U0CSR = U_MODE | U_RE | U_TXB;
/*UART mode, receiver enable, TX done*/
54
55
/*set priority group of group 3 to highest, so the UART won't miss bytes*/
56
IP1 |= IP1_3;
57
IP0 |= IP0_3;
58
}
59
/*---------------------------------------------------------------------------*/
60
/* Write one byte over the UART. */
61
void
62
uart0_writeb(uint8_t byte)
63
{
64
IRCON2_UTX0IF = 0;
65
U0BUF = byte;
66
while
(!IRCON2_UTX0IF);
/* Wait until byte has been transmitted. */
67
IRCON2_UTX0IF = 0;
68
}
69
#endif
Generated on Thu Apr 24 2014 16:26:15 for Contiki-Inga 3.x by
1.8.3.1