0x4000_4000 是一個32位元的記憶體位址,所以我需要一個 uint32_t* 去接他
uint32_t* ptr_mode;
ptr_mode = (uint32_t*)(0x40004000 + 0x1c0);
*ptr_mode = 0x00000100;
uint32_t* ptr_value;
ptr_value = (uint32_t*)(0x40004000 + 0x1c8);
*ptr_value = 0xFFFFFFEF; 負源觸發
補充說明 : 也可以使用 Keil 的 tool 看,如下圖所示:
uint32_t* ptr_mode;
ptr_mode = (uint32_t*)(0x40004000 + 0x1c0);
*ptr_mode = 0x00000100;
uint32_t* ptr_value;
ptr_value = (uint32_t*)(0x40004000 + 0x1c8);
*ptr_value = 0xFFFFFFEF;
//----------------和下面寫法一樣-----------------------------------
GPIO_SetMode(PH, BIT4, GPIO_MODE_OUTPUT);
GPIO_SetMode(PH, BIT5, GPIO_MODE_OUTPUT);
GPIO_SetMode(PH, BIT6, GPIO_MODE_OUTPUT);
LED_YELLOW = 0;//PH5
LED_RED = 1; //PH4
LED_GREEN = 0; //PH6
先用 Keil 的Tool 看一下 按下Button 的狀態
GPIO_SetMode(PH, BIT4, GPIO_MODE_OUTPUT);
GPIO_SetMode(PH, BIT5, GPIO_MODE_OUTPUT);
GPIO_SetMode(PH, BIT6, GPIO_MODE_OUTPUT);
LED_YELLOW = 1;//PH5
LED_RED = 1; //PH4
LED_GREEN = 1; //PH6
GPIO_SetMode(PH, BIT0, GPIO_MODE_INPUT);
/* Got no where to go, just loop forever */
while(1) {
if(PH0 == 0){
LED_RED = 0; //PH4
}
if(PH0 == 1){
LED_RED = 1; //PH4
}
}