/* start the main program */ void main() { uint8_t value; GPIO_PinDirection(SW1,INPUT); // Configure the switch pin as Input GPIO_PinDirection(Buzzer,OUTPUT); // Configure the Buzzer pin as OUTPUT while(1) { value = GPIO_PinRead(SW1); // Read the switch status GPIO_PinWrite(Buzzer,!value); // ON/OFF theBuzzer as per switch status } }
int main (void) { SystemInit(); GPIO_PinDirection(LED1,OUTPUT); /* Configure the pins as Output to blink the Leds*/ GPIO_PinDirection(LED2,OUTPUT); EINT_AttachInterrupt(EINT0,myExtIntrIsr_0,FALLING); /* myExtIntrIsr_0 will be called by EINT0_IRQHandler */ EINT_AttachInterrupt(EINT1,myExtIntrIsr_1,FALLING); /* myExtIntrIsr_1 will be called by EINT1_IRQHandler */ while(1) { //do nothing } }
int main() { uint8_t value; SystemInit(); /* Clock and PLL configuration */ GPIO_PinFunction(MY_SWITCH,PINSEL_FUNC_0); /* Configure Pin for Gpio */ GPIO_PinDirection(MY_SWITCH,INPUT); /* Configure the switch pin as Input */ GPIO_PinFunction(MY_LED,PINSEL_FUNC_0); /* Configure Pin for Gpio */ GPIO_PinDirection(MY_LED,OUTPUT); /* Configure the Led pin as OUTPUT */ while(1) { value = GPIO_PinRead(MY_SWITCH); /* Read the switch status */ GPIO_PinWrite(MY_LED,value); /* ON/OFF the led as per switch status */ } }
int main() { SystemInit(); SystemCoreClockUpdate(); GPIO_PinDirection(P2_0,OUTPUT); GPIO_PinDirection(P2_1,OUTPUT); GPIO_PinDirection(P2_2,OUTPUT); GPIO_PinDirection(P2_3,OUTPUT); GPIO_PinWrite(P2_0,1); UsbSerial_Init(9600); GPIO_PinWrite(P2_1,1); while(1) { UsbSerial_TxString(" Welcome to ARM Serial Programming by ExploreEmbedded\n\r"); } }
int main (void) { SystemInit(); GPIO_PinDirection(LED1,OUTPUT); /* Configure the pins as Output to blink the Leds*/ GPIO_PinDirection(LED2,OUTPUT); TIMER_Init(0,100000); /* Configure timer0 to generate 100ms(100000us) delay*/ TIMER_Init(1,500000); /* Configure timer1 to generate 500ms(500000us) delay*/ TIMER_AttachInterrupt(0,myTimerIsr_0); /* myTimerIsr_0 will be called by TIMER0_IRQn */ TIMER_AttachInterrupt(1,myTimerIsr_1); /* myTimerIsr_1 will be called by TIMER1_IRQn */ TIMER_Start(0); /* Start the Timers */ TIMER_Start(1); while(1) { //do nothing } }
/************************************************************************************************** void LCD_SetUp( pin numbers of lcd) *************************************************************************************************** * Function name: LCD_SetUp() * I/P Arguments: uint8_t RS: Pin where RS is connected uint8_t RW: Pin where RW is connected (P_NC if not connected) uint8_t EN: Pin where EN is connected uint8_t D0: Pin where D0 is connected (P_NC if not connected for 4-bit mode) uint8_t D1: Pin where D1 is connected (P_NC if not connected for 4-bit mode) uint8_t D2: Pin where D2 is connected (P_NC if not connected for 4-bit mode) uint8_t D3: Pin where D3 is connected (P_NC if not connected for 4-bit mode) uint8_t D4: Pin where D4 is connected uint8_t D5: Pin where D5 is connected uint8_t D6: Pin where D6 is connected uint8_t D7: Pin where D7 is connected * Return value : none * description :This function is used to configure the controller pins for LCD operation. Pass the pin numbers where the RS,RW,EN, D0-D7 are connected as parameters. In case of four bit mode pass P_NC as parameter for D0-D3. If RW is not used then pass P_NC as parameter for RS. **************************************************************************************************/ void LCD_SetUp(uint8_t RS, uint8_t RW, uint8_t EN, uint8_t D0, uint8_t D1, uint8_t D2, uint8_t D3, uint8_t D4, uint8_t D5, uint8_t D6, uint8_t D7 ) { /* Copy the PIN numbers where the LCD is connected */ LCDConfig.RS = RS; LCDConfig.RW = RW; LCDConfig.EN = EN; LCDConfig.D0 = D0; LCDConfig.D1 = D1; LCDConfig.D2 = D2; LCDConfig.D3 = D3; LCDConfig.D4 = D4; LCDConfig.D5 = D5; LCDConfig.D6 = D6; LCDConfig.D7 = D7; if((D0 == P_NC) || (D1 == P_NC) || (D2 == P_NC) || (D3 == P_NC)) { LCDConfig.v_LcdMode_U8 = 4; // Select 4-bit mode as D0-D3 are not used(P_NC) } else { LCDConfig.v_LcdMode_U8 = 8; // 8-bit mode configure D0-D3 as output. GPIO_PinDirection(D0,OUTPUT); GPIO_PinDirection(D1,OUTPUT); GPIO_PinDirection(D2,OUTPUT); GPIO_PinDirection(D3,OUTPUT); } /* Configure RS,RW,EN, D4-D7 as Output for both 4/8-bit mode.*/ GPIO_PinDirection(RS,OUTPUT); GPIO_PinDirection(RW,OUTPUT); GPIO_PinDirection(EN,OUTPUT); GPIO_PinDirection(D4,OUTPUT); GPIO_PinDirection(D5,OUTPUT); GPIO_PinDirection(D6,OUTPUT); GPIO_PinDirection(D7,OUTPUT); }