Simple mbed library with macros

Dependents:   SimpleTimer SimpleUART SimpleTimer Stoppuhr1

mbed_globals.h

Committer:
Alkorin
Date:
2010-11-08
Revision:
3:0b94bf95c552
Parent:
2:e6b2d22fbf75
Child:
4:afddc4848b6c

File content as of revision 3:0b94bf95c552:

#ifndef __MBED_GLOBALS_H__
#define __MBED_GLOBALS_H__

#include <LPC17xx.h>

/* GLOBALS MACRO */
#define GET_REGISTER8(reg)  *(volatile uint8_t *)(reg)
#define GET_REGISTER16(reg) *(volatile uint16_t *)(reg)
#define GET_REGISTER32(reg) *(volatile uint32_t *)(reg)

#define SET_REGISTER8(reg, val)  *(uint8_t *)(reg)=(val)
#define SET_REGISTER16(reg, val) *(uint16_t *)(reg)=(val)
#define SET_REGISTER32(reg, val) *(uint32_t *)(reg)=(val)

// See 34.3.2.5 p740
#define BIT_BANDING_ADDRESS(reg, bit) (((reg) & 0xF0000000) | (0x02000000) | (((reg) & 0x000FFFFF) << 5) | ((bit) << 2))
#define GET_BIT_VALUE(reg, bit) GET_REGISTER32(BIT_BANDING_ADDRESS(reg, bit))

#endif