Skip to content

Commit 4b99ca3

Browse files
committed
Changed to K64F example
1 parent 817d64d commit 4b99ca3

File tree

3 files changed

+23
-74
lines changed

3 files changed

+23
-74
lines changed

Baremetal-Blinky/README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
## Baremetal Blinky example using Mbed OS
22

3-
This guide reviews the steps required to build and run a baremetal Blinky application on TI's CC3220SF LaunchXL platform without using DigitalOut class and timers.
3+
This guide reviews the steps required to build and run a baremetal Blinky application on FRDM-K64F without using DigitalOut class and timers.
44

55
Please install [Mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli).
66

7-
This example retrieves code from https://github.com/ARMmbed/mbed-os-ti-port. It's a private repo; please contact [email protected] to request access.
8-
97
### Import the example application
108

119
From the command-line, import the example:
1210

1311
```
1412
git clone https://github.com/ARMmbed/mbed-os-examples-docs_only.git
15-
cd Baremetal-Blinky
13+
cd mbed-os-examples-docs_only/Baremetal-Blinky
1614
mbed config root .
1715
mbed deploy
1816
```
@@ -21,12 +19,12 @@ mbed deploy
2119

2220

2321
```
24-
mbed compile -m cc3220sf -t gcc_arm
22+
mbed compile -m k64f -t gcc_arm
2523
```
2624

2725
#### Program your board
2826

2927
1. Connect your Mbed device to the computer over USB.
3028
2. Copy the binary file to the Mbed device.
31-
3. Observe the red LED blinking.
29+
3. Observe LED blinking.
3230

Baremetal-Blinky/main.cpp

Lines changed: 18 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,33 @@
11
#include "mbed.h"
2+
#include "MK64F12.h"
23

3-
// Port A0: 0x40004000 GPIO0 to GPIO7
4-
// Port A1: 0x40005000 GPIO8 to GPIO15 Use GPIO13 (SW2) as input, GPIO9(D10 Red) as output
5-
// Port A2: 0x40006000 GPIO16 to GPIO23
6-
// Port A3: 0x40007000 GPIO24 to GPIO31
7-
8-
#define WAIT_CYCLES_LONG 10000000
9-
#define WAIT_CYCLES_SHORT 1000000
10-
#define INPUT_PIN_PORTA1 5
11-
#define OUTPUT_PIN_PORTA1 1
12-
#define GPIO_PORTA1_ADDRESS 0x40005000
13-
#define GPIO_PAD_CONFIG_9_ADDRESS 0x4402E0C4
14-
#define OFFSET_DIR 0x400
15-
#define OFFSET_DATA 0
16-
#define ARCM_BASE 0x44025000
17-
#define PRCM_RUN_MODE_CLK 0x00000001
18-
#define PRCM_SLP_MODE_CLK 0x00000100
19-
#define GPIO_PAD_CONFIG_9 0x4402E0C4
20-
#define PAD_MODE_MASK 0x0000000F
21-
22-
static void set_gpio_dir()
4+
void bm_gpio_init(void)
235
{
24-
// Configure direction Bit 7:0 DIR, 0 = input, 1 = output
25-
*((volatile unsigned long*)(GPIO_PORTA1_ADDRESS + OFFSET_DIR)) &= ~0x20; // Configure SW2 as input
26-
*((volatile unsigned long*)(GPIO_PORTA1_ADDRESS + OFFSET_DIR)) |= 0x2; // Configure D10 as output
27-
6+
SIM->SCGC5 = SIM_SCGC5_PORTB_MASK;
7+
PORTB->PCR[22] = PORT_PCR_MUX(1U);
8+
PTB->PDDR = (1U << 22U);
289
}
2910

30-
static const unsigned long g_ulPinToPadMap[64] =
11+
void bm_delay(void)
3112
{
32-
10,11,12,13,14,15,16,17,255,255,18,
33-
19,20,21,22,23,24,40,28,29,25,255,
34-
255,255,255,255,255,255,255,255,255,255,255,
35-
255,255,255,255,255,255,255,255,255,255,255,
36-
31,255,255,255,255,0,255,32,30,255,1,
37-
255,2,3,4,5,6,7,8,9
38-
};
39-
40-
void PinModeSet(unsigned long ulPin,unsigned long ulPinMode)
41-
{
42-
unsigned long ulPad;
43-
44-
// Get the corresponding Pad
45-
ulPad = g_ulPinToPadMap[ulPin & 0x3F];
46-
47-
// Calculate the register address
48-
ulPad = ((ulPad << 2) + (0x4402E000+0x000000A0));
13+
volatile unsigned int i,j;
4914

50-
// Set the mode.
51-
*((volatile unsigned long*)(ulPad)) = (((*((volatile unsigned long*)(ulPad))) & ~PAD_MODE_MASK) | ulPinMode) & ~(3<<10);
15+
for (i = 0U; i < 100000U; i++) {
16+
for (j = 0U; j < 100U; j++) {
17+
__asm__("nop");
18+
}
19+
}
5220
}
5321

54-
int main()
22+
int main(void)
5523
{
56-
PinModeSet(0x0000003F,0x000000000);
57-
*((volatile unsigned long*)(ARCM_BASE + 0x58)) |= PRCM_RUN_MODE_CLK || PRCM_SLP_MODE_CLK;
58-
59-
unsigned long wait_cycles_in_use = WAIT_CYCLES_SHORT;
60-
volatile unsigned long delay = 0;
24+
bm_gpio_init();
6125

62-
set_gpio_dir();
63-
*((volatile unsigned long*)(GPIO_PAD_CONFIG_9))|= 0x220;
64-
65-
while (true)
66-
{
67-
68-
// Check if SW2 is pressed
69-
if (*(volatile unsigned long *)(GPIO_PORTA1_ADDRESS + OFFSET_DATA + ((1 << INPUT_PIN_PORTA1) << 2)))
70-
{
71-
wait_cycles_in_use = WAIT_CYCLES_LONG;
72-
}
26+
PTB->PSOR = (1U << 22U);
7327

74-
*(volatile unsigned long *)(GPIO_PORTA1_ADDRESS + OFFSET_DATA + ((1 << OUTPUT_PIN_PORTA1) << 2)) = (OUTPUT_PIN_PORTA1 << 1);
75-
delay = wait_cycles_in_use;
76-
while (delay--);
77-
*(volatile unsigned long *)(GPIO_PORTA1_ADDRESS + OFFSET_DATA + ((1 << OUTPUT_PIN_PORTA1) << 2)) = 0;
78-
delay = wait_cycles_in_use;
79-
while (delay--);
28+
while (1) {
29+
PTB->PTOR = (1U << 22U);
30+
bm_delay();
8031
}
8132
}
8233

Baremetal-Blinky/mbed-os.lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://github.com/ARMmbed/mbed-os-ti-port/#1304ebdb5e8d1e6d13aabe1360813b75f58c0828
1+
https://github.com/ARMmbed/mbed-os/#2fd0c5cfbd83fce62da6308f9d64c0ab64e1f0d6

0 commit comments

Comments
 (0)