From e3d457d72f59bd442a3a8d13b311d7c8444e177d Mon Sep 17 00:00:00 2001 From: Kleidi Bujari Date: Fri, 4 Oct 2024 17:30:14 -0400 Subject: labs 1,2 --- .../labs/lab1/Boards/Keil/MCB1700/Blinky_ULp/LED.c | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 F2024/coe718/labs/lab1/Boards/Keil/MCB1700/Blinky_ULp/LED.c (limited to 'F2024/coe718/labs/lab1/Boards/Keil/MCB1700/Blinky_ULp/LED.c') 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<