Skip to content

Commit 1092e48

Browse files
committed
2.0.8
1 parent dec9974 commit 1092e48

File tree

118 files changed

+40922
-2323
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+40922
-2323
lines changed

lesson-39/tm4c123-uc_ao-keil/bsp.c

+17-11
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,28 @@ void App_TCBInitHook (OS_TCB *ptcb) { (void)ptcb; }
7575

7676
/* BSP functions ===========================================================*/
7777
void BSP_init(void) {
78-
SYSCTL->RCGCGPIO |= (1U << 5); /* enable Run Mode for GPIOF */
78+
/* enable clock for to the peripherals used by this application... */
7979
SYSCTL->GPIOHBCTL |= (1U << 5); /* enable AHB for GPIOF */
80+
SYSCTL->RCGCGPIO |= (1U << 5); /* enable Run mode for GPIOF */
8081

81-
/* make sure the Run Mode and AHB-enable take effects
82-
* before accessing the peripherals
83-
*/
84-
__ISB(); /* Instruction Synchronization Barrier */
85-
__DSB(); /* Data Memory Barrier */
86-
82+
/* configure LEDs (digital output) */
8783
GPIOF_AHB->DIR |= (LED_RED | LED_BLUE | LED_GREEN);
8884
GPIOF_AHB->DEN |= (LED_RED | LED_BLUE | LED_GREEN);
85+
GPIOF_AHB->DATA_Bits[LED_RED | LED_BLUE | LED_GREEN] = 0U;
86+
87+
/* configure switches... */
88+
89+
/* unlock access to the SW2 pin because it is PROTECTED */
90+
GPIOF_AHB->LOCK = 0x4C4F434BU; /* unlock GPIOCR register for SW2 */
91+
/* commit the write (cast const away) */
92+
*(uint32_t volatile *)&GPIOF_AHB->CR = 0x01U;
93+
94+
GPIOF_AHB->DIR &= ~(BTN_SW1 | BTN_SW2); /* input */
95+
GPIOF_AHB->DEN |= (BTN_SW1 | BTN_SW2); /* digital enable */
96+
GPIOF_AHB->PUR |= (BTN_SW1 | BTN_SW2); /* pull-up resistor enable */
8997

90-
/* configure switch SW1 */
91-
GPIOF_AHB->DIR &= ~BTN_SW1; /* input */
92-
GPIOF_AHB->DEN |= BTN_SW1; /* digital enable */
93-
GPIOF_AHB->PUR |= BTN_SW1; /* pull-up resistor enable */
98+
*(uint32_t volatile *)&GPIOF_AHB->CR = 0x00U;
99+
GPIOF_AHB->LOCK = 0x0; /* lock GPIOCR register for SW2 */
94100
}
95101
/*..........................................................................*/
96102
void BSP_start(void) {

0 commit comments

Comments
 (0)