Professional Documents
Culture Documents
Led Arm7
Led Arm7
H>
/* LPC21xx definitions */
SW_IO_DIR IODIR0
//to feed input
LED_IO_DIR IODIR1 //to show output
INIT_SWITCHES() (IODIR0 &= ~((1 << 24)|(1 << 23)))//set as input
INIT_LEDS()
(IODIR1 |= ((1 << 13)|(1 << 12))) //set as output
Input
: Void
Output
: None
Note
:
******************************************************************************
*/
Input
: Void
Output
: None
Note
:
******************************************************************************
*/
/*void turn_off_all_leds()
{
IOCLR0 |= LED_MASK;
} */
/**
*****************************************************************************
Function Name : turn_off_all_leds()
Description
Input
: Void
Output
: None
Note
:
******************************************************************************
*/
/*void turn_on_all_leds()
{
LED_SET |= LED_MASK;
} */
int main (void) {
unsigned int sw_mask;
unsigned int index;
INIT_LEDS();
INIT_SWITCHES();
/* LED var */
// configure the gpio's connected by LEDs.
// configure the gpio's connected by Switches.
while (1) {
sw_mask = SW_IO_PIN & SWITCH_MASK;
for(index = 0; index < 3; index++)
{
if(sw_mask & (1 << (index + 17)))
{
turn_on_led(index + 1);
corresponds to specific LED is ON.
}
else
{
turn_off_led(index + 1);
h corresponds to specific LED is OFF.
}
}
//
wait();
}
}
// Read switches
//check the status of switches
// Turn on the LED if a switch