Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
8552c04c
Commit
8552c04c
authored
11 years ago
by
Oleg Hahm
Browse files
Options
Downloads
Patches
Plain Diff
corrected and translated comments
parent
7a2cc4ae
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
msb-430-common/board_init.c
+84
-84
84 additions, 84 deletions
msb-430-common/board_init.c
with
84 additions
and
84 deletions
msb-430-common/board_init.c
+
84
−
84
View file @
8552c04c
...
...
@@ -9,7 +9,7 @@ static volatile uint32_t __msp430_cpu_speed = MSP430_INITIAL_CPU_SPEED;
/*---------------------------------------------------------------------------*/
static
uint8_t
calc_umctl
(
uint16_t
br
)
{
/
/
from TI slaa049
/
*
from TI slaa049
*/
register
uint8_t
CMOD
=
256
*
br
-
256
*
(
br
+
1
)
/
2
;
register
uint8_t
c
=
0
;
register
int
i
=
0
;
...
...
@@ -17,12 +17,12 @@ static uint8_t calc_umctl(uint16_t br)
a
<<=
1
;
do
{
if
(
a
&
0x80
)
{
/
/
Overflow to integer?
a
=
a
-
128
+
CMOD
;
/
/
Yes, subtract 1.000000
if
(
a
&
0x80
)
{
/
*
Overflow to integer?
*/
a
=
a
-
128
+
CMOD
;
/
*
Yes, subtract 1.000000
*/
c
|=
0x80
;
}
else
{
a
+=
CMOD
;
/
/
No, add fraction
a
+=
CMOD
;
/
*
No, add fraction
*/
}
if
(
i
==
7
)
{
...
...
@@ -37,71 +37,71 @@ static uint8_t calc_umctl(uint16_t br)
static
void
msb_ports_init
(
void
)
{
/
/
Port 1: Free port, for energy saving all outputs are set to zero.
P1SEL
=
0x00
;
/
/
Port1
Zweitf
un
k
tion
P1OUT
=
0x00
;
/
/
Port1 Ausgangsregister: 00000000 = 0x00
P1DIR
=
0xFF
;
/
/
Port1 Direction: 11111111 = 0xFF
P2SEL
=
0x20
;
/
/
Port2
Zweitf
un
k
tion
P2OUT
=
0x00
;
/
/
Port2
Ausgangs
register: 00000000 = 0x00
P2DIR
=
0x1C
;
/
/
Port2 Direction: 00011010 = 0x1C
/
/
0 - P2.0 [IN ] -
/
/
0 - P2.1 [OUT] -
/
/
1 - P2.2 [IN ] -
/
/
1 - P2.3 [OUT] -
/
/
1 - P2.4 [OUT] -
/
/
0 - P2.5 [IN ] -
/
/
0 - P2.6 [IN ] - SD
-KARTE
Protect
/
/
0 - P2.7 [IN ] - SD
-KARTE
Detect
P3SEL
=
0xC0
;
/
/
Port3
Zweitfunktion
P3OUT
=
0x49
;
/
/
Port3
Ausgangs
register: 0
0
001001
=
0x
09
P3DIR
=
0xAB
;
/
/
Port3 Direction
/
/
1 - P3.0
/
/
1 - P3.1
/
/
0 - P3.2
/
/
1 - P3.3
/
/
0 - P3.4 [IN ] - SHT 11 DATA (OUT/IN)
/
/
1 - P3.5 [OUT] - SHT 11 CLK
/
/
0 - P3.6 [2-Funktion] - RS232_RxD
/
/
0
- P3.7 [2-Funktion] - RS232_TxD
/
/
Port 4: Free port, for energy saving all outputs are set to zero.
P4SEL
=
0x00
;
/
/
Port4
Zweitf
un
k
tion
P4OUT
=
0x00
;
/
/
Port4
Ausgangs
register: 00000000 = 0x00
P4DIR
=
0xFF
;
/
/
Port4 Direction: 11111111 = 0xFF
/
/
1 - P4.0 [OUT] - unused
/
/
1 - P4.1 [OUT] - unused
/
/
1 - P4.2 [OUT] - unused
/
/
1 - P4.3 [OUT] - unused
/
/
1 - P4.4 [OUT] - unused
/
/
1 - P4.5 [OUT] - unused
/
/
1 - P4.6 [OUT] - unused
/
/
1 - P4.7 [OUT] - unused
P5SEL
=
0x00
;
/
/
Port5
Zweitf
un
k
tion: 00000000 = 0x00
P5OUT
=
0x80
;
/
/
Port5
Ausgangs
register: 00001001 = 0x09
P5DIR
=
0xFF
;
/
/
Port5 Direction: 11111011 = 0xFB
/
/
1 - P5.0 [OUT] - SD
-KARTE
/CS
/
/
1 - P5.1 [OUT] - SD
-KARTE DI
/
/
0 - P5.2 [IN ] - SD
-KARTE DO
/
/
1 - P5.3 [OUT] - SD
-KARTE
DCLK
/
/
1 - P5.4 [OUT] - MMA GS1
/
/
1 - P5.5 [OUT] - MMA GS2
/
/
1 - P5.6 [OUT] - MMA /SLEEP
/
/
1 - P5.7 [OUT] - LED_R
OT
0-
a
n, 1-
aus
P6SEL
=
0x00
;
/
/
Port6
Zweitf
un
k
tion = 0x07
P6OUT
=
0x00
;
/
/
Port6
Ausgangs
register: 00000000 = 0x00
P6DIR
=
0xFF
;
/
/
Port6 Direction: 11111000 = 0xF8
/
/
0 - P6.0 [AD-IN] - MMA X-A
chse
/
/
0 - P6.1 [AD-IN] - MMA Y-A
chse
/
/
0 - P6.2 [AD-IN] - MMA Z-A
chse
/
/
1 - P6.3 [OUT] - unused
/
/
1 - P6.4 [OUT] - unused
/
/
1 - P6.5 [OUT] - unused
/
/
1 - P6.6 [OUT] - unused
/
/
1 - P6.7 [OUT] - unused
/
*
Port 1: Free port, for energy saving all outputs are set to zero.
*/
P1SEL
=
0x00
;
/
*
Port1
I/O F
un
c
tion
*/
P1OUT
=
0x00
;
/
*
Port1 Ausgangsregister: 00000000 = 0x00
*/
P1DIR
=
0xFF
;
/
*
Port1 Direction: 11111111 = 0xFF
*/
P2SEL
=
0x20
;
/
*
Port2
I/O F
un
c
tion
*/
P2OUT
=
0x00
;
/
*
Port2
Output
register: 00000000 = 0x00
*/
P2DIR
=
0x1C
;
/
*
Port2 Direction: 00011010 = 0x1C
*/
/
*
0 - P2.0 [IN ] -
*/
/
*
0 - P2.1 [OUT] -
*/
/
*
1 - P2.2 [IN ] -
*/
/
*
1 - P2.3 [OUT] -
*/
/
*
1 - P2.4 [OUT] -
*/
/
*
0 - P2.5 [IN ] -
*/
/
*
0 - P2.6 [IN ] - SD
C
Protect
*/
/
*
0 - P2.7 [IN ] - SD
C
Detect
*/
P3SEL
=
0xC0
;
/
*
Port3
Pins 6 & 7 for USART */
P3OUT
=
0x49
;
/
*
Port3
Output
register: 0
1
001001
:
0x
49 */
P3DIR
=
0xAB
;
/
*
Port3 Direction
: 10101011: 0xAB */
/
*
1 - P3.0
*/
/
*
1 - P3.1
*/
/
*
0 - P3.2
*/
/
*
1 - P3.3
*/
/
*
0 - P3.4 [IN ] - SHT 11 DATA (OUT/IN)
*/
/
*
1 - P3.5 [OUT] - SHT 11 CLK
*/
/
*
0 - P3.6 [2-Funktion] - RS232_RxD
*/
/
*
1
- P3.7 [2-Funktion] - RS232_TxD
*/
/
*
Port 4: Free port, for energy saving all outputs are set to zero.
*/
P4SEL
=
0x00
;
/
*
Port4
I/O F
un
c
tion
*/
P4OUT
=
0x00
;
/
*
Port4
Output
register: 00000000 = 0x00
*/
P4DIR
=
0xFF
;
/
*
Port4 Direction: 11111111 = 0xFF
*/
/
*
1 - P4.0 [OUT] - unused
*/
/
*
1 - P4.1 [OUT] - unused
*/
/
*
1 - P4.2 [OUT] - unused
*/
/
*
1 - P4.3 [OUT] - unused
*/
/
*
1 - P4.4 [OUT] - unused
*/
/
*
1 - P4.5 [OUT] - unused
*/
/
*
1 - P4.6 [OUT] - unused
*/
/
*
1 - P4.7 [OUT] - unused
*/
P5SEL
=
0x00
;
/
*
Port5
I/O F
un
c
tion: 00000000 = 0x00
*/
P5OUT
=
0x80
;
/
*
Port5
Output
register: 00001001 = 0x09
*/
P5DIR
=
0xFF
;
/
*
Port5 Direction: 11111011 = 0xFB
*/
/
*
1 - P5.0 [OUT] - SD
C
/CS
*/
/
*
1 - P5.1 [OUT] - SD
C DI */
/
*
0 - P5.2 [IN ] - SD
C DO */
/
*
1 - P5.3 [OUT] - SD
C
DCLK
*/
/
*
1 - P5.4 [OUT] - MMA GS1
*/
/
*
1 - P5.5 [OUT] - MMA GS2
*/
/
*
1 - P5.6 [OUT] - MMA /SLEEP
*/
/
*
1 - P5.7 [OUT] - LED_R
ED
0-
o
n, 1-
off */
P6SEL
=
0x00
;
/
*
Port6
I/O F
un
c
tion = 0x07
*/
P6OUT
=
0x00
;
/
*
Port6
Output
register: 00000000 = 0x00
*/
P6DIR
=
0xFF
;
/
*
Port6 Direction: 11111000 = 0xF8
*/
/
*
0 - P6.0 [AD-IN] - MMA X-A
xis */
/
*
0 - P6.1 [AD-IN] - MMA Y-A
xis */
/
*
0 - P6.2 [AD-IN] - MMA Z-A
xis */
/
*
1 - P6.3 [OUT] - unused
*/
/
*
1 - P6.4 [OUT] - unused
*/
/
*
1 - P6.5 [OUT] - unused
*/
/
*
1 - P6.6 [OUT] - unused
*/
/
*
1 - P6.7 [OUT] - unused
*/
}
void
msp430_set_cpu_speed
(
uint32_t
speed
)
...
...
@@ -110,14 +110,14 @@ void msp430_set_cpu_speed(uint32_t speed)
__msp430_cpu_speed
=
speed
;
msp430_init_dco
();
uint16_t
br
;
UCTL1
=
SWRST
|
CHAR
;
/
/
8-bit character
UTCTL1
|=
SSEL1
|
URXSE
;
/
/
UCLK = MCLK
/
/
activate
U1ME
|=
UTXE1
|
URXE1
;
/
/
Enable USART1 TXD/RXD
UCTL1
=
SWRST
|
CHAR
;
/
*
8-bit character
*/
UTCTL1
|=
SSEL1
|
URXSE
;
/
*
UCLK = MCLK
*/
/
*
activate
*/
U1ME
|=
UTXE1
|
URXE1
;
/
*
Enable USART1 TXD/RXD
*/
br
=
(
uint16_t
)(
__msp430_cpu_speed
/
115200uL
);
UBR01
=
br
;
/
/
set baudrate
UBR01
=
br
;
/
*
set baudrate
*/
UBR11
=
br
>>
8
;
UMCTL1
=
calc_umctl
(
br
);
/
/
set modulation
UMCTL1
=
calc_umctl
(
br
);
/
*
set modulation
*/
ME2
|=
(
UTXE1
|
URXE1
);
UCTL1
&=
~
SWRST
;
...
...
@@ -135,22 +135,22 @@ msp430_init_dco()
/*------------------ use external oszillator -----------------------*/
uint16_t
i
;
/
/
Stop watchdog
/
*
Stop watchdog
*/
WDTCTL
=
WDTPW
+
WDTHOLD
;
//Init crystal for mclk
//XT2 = HF XTAL
BCSCTL1
=
RSEL2
;
/
/
Wait for xtal to stabilize
/
*
Wait for xtal to stabilize
*/
do
{
IFG1
&=
~
OFIFG
;
/
/
Clear oscillator fault flag
IFG1
&=
~
OFIFG
;
/
*
Clear oscillator fault flag
*/
for
(
i
=
0xFF
;
i
>
0
;
i
--
);
/
/
Time for flag to set
for
(
i
=
0xFF
;
i
>
0
;
i
--
);
/
*
Time for flag to set
*/
}
while
((
IFG1
&
OFIFG
)
!=
0
);
/
/
Oscillator fault flag still set?
while
((
IFG1
&
OFIFG
)
!=
0
);
/
*
Oscillator fault flag still set?
*/
BCSCTL2
=
SELM_2
+
SELS
;
/
/
MCLK und SMCLK = XT2 (safe)
BCSCTL2
=
SELM_2
+
SELS
;
/
*
MCLK und SMCLK = XT2 (safe)
*/
#else
/* Thdeltais code taken from the FU Berlin sources and reformatted. */
int
delta
=
__msp430_cpu_speed
>>
12
;
...
...
@@ -163,7 +163,7 @@ msp430_init_dco()
BCSCTL1
=
0xa4
;
/* ACLK is devided by 4. RSEL=6 no division for MCLK
and SSMCLK. XT2 is off. */
/
/
Init FLL to desired frequency using the 32762Hz crystal
/
*
Init FLL to desired frequency using the 32762Hz crystal
*/
#if MSP430_HAS_DCOR
BCSCTL2
=
0x01
;
#else
...
...
@@ -175,8 +175,8 @@ msp430_init_dco()
for
(
i
=
0xffff
;
i
>
0
;
i
--
);
/* Delay for XTAL to settle */
CCTL2
=
CCIS0
+
CM0
+
CAP
;
/
/
Define CCR2, CAP, ACLK
TACTL
=
TASSEL1
+
TACLR
+
MC1
;
/
/
SMCLK, continous mode
CCTL2
=
CCIS0
+
CM0
+
CAP
;
/
*
Define CCR2, CAP, ACLK
*/
TACTL
=
TASSEL1
+
TACLR
+
MC1
;
/
*
SMCLK, continous mode
*/
while
(
1
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment