#define nop()asm volatile ("nop")
#define SETTINGS_GPIO_OUT (PUP_DISABLE | PDN_DISABLE | SLEWRATE_SLOW | FILTER_DISABLE)//SLEWRATE_SLOW | FILTER_ENABLE)
#define SETTINGS_GPIO_IN (PUP_DISABLE | PDN_DISABLE | SLEWRATE_SLOW | INBUF_ENABLE | FILTER_DISABLE)
//some correlation can be drawn from pg 232 of UM10503.pdf
int main(void) {
//these next two are working for setting up the LED
//BOOT0_LED with pull down enabled and pull up disabled (MD_PDN = 0x3<<3)
scu_pinmux(0x1, 1, MD_PDN, FUNC0); // P1_1,FUNC0 => GPIO0[8]
GPIO_SetDir(0,1<<8, 1);
//these pins are on J9, pins 10 and 4 respectively (the odd pins are ground)
scu_pinmux(0x1, 10, SETTINGS_GPIO_IN, FUNC0); //GPIO1[3], P1_10 //set its mode to enable the input buffer, so we can use as input
scu_pinmux(0x1, 7, SETTINGS_GPIO_OUT, FUNC0); //GPIO1[0], P1_7 //FUNC0 is normal GPIO setting for these pins
GPIO_SetDir(1,1<<3, 0); //GPIO1[3], P1_10 ... INPUT == 0
GPIO_SetDir(1,1<<0, 1); //GPIO1[0], P1_7 ... OUTPUT == 1
//Clear LED
GPIO_ClearValue(0,1<<8);
while(1) {
//wait while an applied clock signal is low, move on when it goes high
while((GPIO_ReadValue(1) & (1<<3))==0){ nop(); }
GPIO_SetValue(1,1<<0);
GPIO_SetValue(0,1<<8);
//wait while an applied clock signal is high, move on when it goes low
while((GPIO_ReadValue(1) & (1<<3))){ nop(); }
GPIO_ClearValue(1,1<<0);
GPIO_ClearValue(0,1<<8);
}
}
|