blob: 8f6ec49f6d53e95a5f2b76d64375a54dcae0f479 (
plain)
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
|
#include"precomp.h"
#include"rsbus.h"
#include"sysctl.h"
void port_init(void)
{
P1DIR |= BIT0+BIT6; // P1.0 P1.6 output
P1OUT = 0;
}
void received(unsigned char* str,int len)
{
rsbus_w(0,str,len);
}
void init_devices(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
if (CALBC1_8MHZ ==0xFF || CALDCO_8MHZ == 0xFF)
while(1)_BIS_SR(CPUOFF); // If calibration constants erased, trap CPU!!
BCSCTL1 = CALBC1_16MHZ; // Set range
DCOCTL = CALDCO_16MHZ; // Set DCO step + modulation£¬DCO=8MHz
BCSCTL3 |= LFXT1S_2; // LFXT1 = VLO
IFG1 &= ~OFIFG; // Clear OSCFault flag
BCSCTL2 |= DIVS_2; // SMCLK = DCO/4 = 4MHz
sysctl_init();
port_init();
rsbus_init(&received);
_BIS_SR(GIE);
}
void main(void)
{
init_devices();
while(1)
sysroutine();
}
|