diff options
Diffstat (limited to 'F2024/coe718/labs/lab1/Boards/Keil/MCB1700/Blinky_ULp/LED.c')
-rwxr-xr-x | F2024/coe718/labs/lab1/Boards/Keil/MCB1700/Blinky_ULp/LED.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/F2024/coe718/labs/lab1/Boards/Keil/MCB1700/Blinky_ULp/LED.c b/F2024/coe718/labs/lab1/Boards/Keil/MCB1700/Blinky_ULp/LED.c new file mode 100755 index 0000000..0cfaedb --- /dev/null +++ b/F2024/coe718/labs/lab1/Boards/Keil/MCB1700/Blinky_ULp/LED.c @@ -0,0 +1,65 @@ +/*---------------------------------------------------------------------------- + + * Name: LED.c + * Purpose: low level LED functions + * Note(s): + *---------------------------------------------------------------------------- + * This file is part of the uVision/ARM development tools. + * This software may only be used under the terms of a valid, current, + * end user licence from KEIL for a compatible version of KEIL software + * development tools. Nothing else gives you the right to use this software. + * + * This software is supplied "AS IS" without warranties of any kind. + * + * Copyright (c) 2009-2011 Keil - An ARM Company. All rights reserved. + *----------------------------------------------------------------------------*/ + +#include "LPC17xx.h" /* LPC17xx definitions */ +#include "LED.h" + +const unsigned long led_mask[] = { 1UL<<28, 1UL<<29, 1UL<<31, 1UL<< 2, + 1UL<< 3, 1UL<< 4, 1UL<< 5, 1UL<< 6 }; +/*---------------------------------------------------------------------------- + initialize LED Pins + *----------------------------------------------------------------------------*/ + +void LED_Init (void) { + + LPC_SC->PCONP |= (1 << 15); /* enable power to GPIO & IOCON */ + + LPC_GPIO1->FIODIR |= 0xB0000000; /* LEDs on PORT1 are output */ + LPC_GPIO2->FIODIR |= 0x0000007C; /* LEDs on PORT2 are output */ +} + +/*---------------------------------------------------------------------------- + Function that turns on requested LED + *----------------------------------------------------------------------------*/ +void LED_On (unsigned int num) { + + if (num < 3) LPC_GPIO1->FIOPIN |= led_mask[num]; + else LPC_GPIO2->FIOPIN |= led_mask[num]; +} + +/*---------------------------------------------------------------------------- + Function that turns off requested LED + *----------------------------------------------------------------------------*/ +void LED_Off (unsigned int num) { + + if (num < 3) LPC_GPIO1->FIOPIN &= ~led_mask[num]; + else LPC_GPIO2->FIOPIN &= ~led_mask[num]; +} + +/*---------------------------------------------------------------------------- + Function that outputs value to LEDs + *----------------------------------------------------------------------------*/ +void LED_Out(unsigned int value) { + int i; + + for (i = 0; i < LED_NUM; i++) { + if (value & (1<<i)) { + LED_On (i); + } else { + LED_Off(i); + } + } +} |