Simple mbed library with macros

Dependents:   SimpleTimer SimpleUART SimpleTimer Stoppuhr1

Committer:
Alkorin
Date:
Mon Nov 08 12:22:35 2010 +0000
Revision:
2:e6b2d22fbf75
Parent:
0:aa3c3d1a5918
Child:
4:afddc4848b6c
Some code cleaning

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Alkorin 0:aa3c3d1a5918 1 #ifndef __LEDS_H__
Alkorin 0:aa3c3d1a5918 2 #define __LEDS_H__
Alkorin 0:aa3c3d1a5918 3
Alkorin 2:e6b2d22fbf75 4 #include "mbed_globals.h"
Alkorin 2:e6b2d22fbf75 5
Alkorin 2:e6b2d22fbf75 6 /** Registers **/
Alkorin 0:aa3c3d1a5918 7 // GPIO1 Mask register, FIOMASK page 122
Alkorin 2:e6b2d22fbf75 8 #define LEDS_GPIO_MASK (LPC_GPIO1_BASE + 0x10)
Alkorin 0:aa3c3d1a5918 9 // GPIO1 Pin register, FIOPIN page 122
Alkorin 2:e6b2d22fbf75 10 #define LEDS_GPIO_PIN (LPC_GPIO1_BASE + 0x14)
Alkorin 0:aa3c3d1a5918 11 // GPIO1 Direction, FIO1DIR page 122
Alkorin 2:e6b2d22fbf75 12 #define LEDS_GPIO_DIR (LPC_GPIO1_BASE + 0x00)
Alkorin 0:aa3c3d1a5918 13
Alkorin 2:e6b2d22fbf75 14 /** Bits **/
Alkorin 0:aa3c3d1a5918 15 #define LED1 (1 << 18)
Alkorin 0:aa3c3d1a5918 16 #define LED2 (1 << 20)
Alkorin 0:aa3c3d1a5918 17 #define LED3 (1 << 21)
Alkorin 0:aa3c3d1a5918 18 #define LED4 (1 << 23)
Alkorin 0:aa3c3d1a5918 19 #define LEDS_MASK (LED1 | LED2 | LED3 | LED4)
Alkorin 0:aa3c3d1a5918 20
Alkorin 2:e6b2d22fbf75 21 /** Macros **/
Alkorin 2:e6b2d22fbf75 22 #define LEDS_INIT() GET_REGISTER32(LEDS_GPIO_DIR) |= LEDS_MASK;
Alkorin 0:aa3c3d1a5918 23
Alkorin 2:e6b2d22fbf75 24 #define LEDS_SET(value) SET_REGISTER32(LEDS_GPIO_MASK, (~LEDS_MASK)); \
Alkorin 2:e6b2d22fbf75 25 SET_REGISTER32(LEDS_GPIO_PIN, (value));
Alkorin 0:aa3c3d1a5918 26
Alkorin 0:aa3c3d1a5918 27 #endif