Simple mbed library with macros
Dependents: SimpleTimer SimpleUART SimpleTimer Stoppuhr1
mbed_globals.h@8:f8b47457fdcf, 2010-11-13 (annotated)
- Committer:
- Alkorin
- Date:
- Sat Nov 13 22:15:12 2010 +0000
- Revision:
- 8:f8b47457fdcf
- Parent:
- 6:9e1310782abf
- Child:
- 10:0f79cde3f231
Added License
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Alkorin | 8:f8b47457fdcf | 1 | /* |
Alkorin | 8:f8b47457fdcf | 2 | * Copyright or © or Copr. 2010, Thomas SOETE |
Alkorin | 8:f8b47457fdcf | 3 | * |
Alkorin | 8:f8b47457fdcf | 4 | * Author e-mail: thomas@soete.org |
Alkorin | 8:f8b47457fdcf | 5 | * |
Alkorin | 8:f8b47457fdcf | 6 | * This software is governed by the CeCILL license under French law and |
Alkorin | 8:f8b47457fdcf | 7 | * abiding by the rules of distribution of free software. You can use, |
Alkorin | 8:f8b47457fdcf | 8 | * modify and/ or redistribute the software under the terms of the CeCILL |
Alkorin | 8:f8b47457fdcf | 9 | * license as circulated by CEA, CNRS and INRIA at the following URL |
Alkorin | 8:f8b47457fdcf | 10 | * "http://www.cecill.info". |
Alkorin | 8:f8b47457fdcf | 11 | * |
Alkorin | 8:f8b47457fdcf | 12 | * As a counterpart to the access to the source code and rights to copy, |
Alkorin | 8:f8b47457fdcf | 13 | * modify and redistribute granted by the license, users are provided only |
Alkorin | 8:f8b47457fdcf | 14 | * with a limited warranty and the software's author, the holder of the |
Alkorin | 8:f8b47457fdcf | 15 | * economic rights, and the successive licensors have only limited |
Alkorin | 8:f8b47457fdcf | 16 | * liability. |
Alkorin | 8:f8b47457fdcf | 17 | * |
Alkorin | 8:f8b47457fdcf | 18 | * In this respect, the user's attention is drawn to the risks associated |
Alkorin | 8:f8b47457fdcf | 19 | * with loading, using, modifying and/or developing or reproducing the |
Alkorin | 8:f8b47457fdcf | 20 | * software by the user in light of its specific status of free software, |
Alkorin | 8:f8b47457fdcf | 21 | * that may mean that it is complicated to manipulate, and that also |
Alkorin | 8:f8b47457fdcf | 22 | * therefore means that it is reserved for developers and experienced |
Alkorin | 8:f8b47457fdcf | 23 | * professionals having in-depth computer knowledge. Users are therefore |
Alkorin | 8:f8b47457fdcf | 24 | * encouraged to load and test the software's suitability as regards their |
Alkorin | 8:f8b47457fdcf | 25 | * requirements in conditions enabling the security of their systems and/or |
Alkorin | 8:f8b47457fdcf | 26 | * data to be ensured and, more generally, to use and operate it in the |
Alkorin | 8:f8b47457fdcf | 27 | * same conditions as regards security. |
Alkorin | 8:f8b47457fdcf | 28 | * |
Alkorin | 8:f8b47457fdcf | 29 | * The fact that you are presently reading this means that you have had |
Alkorin | 8:f8b47457fdcf | 30 | * knowledge of the CeCILL license and that you accept its terms. |
Alkorin | 8:f8b47457fdcf | 31 | */ |
Alkorin | 8:f8b47457fdcf | 32 | |
Alkorin | 5:b3aa0a49e21f | 33 | #ifndef __MBED_GLOBALS_H__ |
Alkorin | 5:b3aa0a49e21f | 34 | #define __MBED_GLOBALS_H__ |
Alkorin | 5:b3aa0a49e21f | 35 | |
Alkorin | 5:b3aa0a49e21f | 36 | #include <LPC17xx.h> |
Alkorin | 5:b3aa0a49e21f | 37 | |
Alkorin | 5:b3aa0a49e21f | 38 | /* GLOBALS MACRO */ |
Alkorin | 5:b3aa0a49e21f | 39 | #define GET_REGISTER8(reg) *(volatile uint8_t *)(reg) |
Alkorin | 5:b3aa0a49e21f | 40 | #define GET_REGISTER16(reg) *(volatile uint16_t *)(reg) |
Alkorin | 5:b3aa0a49e21f | 41 | #define GET_REGISTER32(reg) *(volatile uint32_t *)(reg) |
Alkorin | 5:b3aa0a49e21f | 42 | |
Alkorin | 5:b3aa0a49e21f | 43 | #define SET_REGISTER8(reg, val) *(uint8_t *)(reg)=(val) |
Alkorin | 5:b3aa0a49e21f | 44 | #define SET_REGISTER16(reg, val) *(uint16_t *)(reg)=(val) |
Alkorin | 5:b3aa0a49e21f | 45 | #define SET_REGISTER32(reg, val) *(uint32_t *)(reg)=(val) |
Alkorin | 5:b3aa0a49e21f | 46 | |
Alkorin | 5:b3aa0a49e21f | 47 | // See 34.3.2.5 p740 |
Alkorin | 5:b3aa0a49e21f | 48 | #define BIT_BANDING_ADDRESS(reg, bit) (((reg) & 0xF0000000) | (0x02000000) | (((reg) & 0x000FFFFF) << 5) | ((bit) << 2)) |
Alkorin | 6:9e1310782abf | 49 | #define GET_BIT_ADDRESS(reg, bit) BIT_BANDING_ADDRESS(((uint32_t)&(reg)), (bit)) |
Alkorin | 6:9e1310782abf | 50 | #define GET_BIT_VALUE(reg, bit) GET_REGISTER32(GET_BIT_ADDRESS((reg), (bit))) |
Alkorin | 6:9e1310782abf | 51 | #define SET_BIT_VALUE(reg, bit, value) SET_REGISTER32(GET_BIT_ADDRESS((reg), (bit)), (value)) |
Alkorin | 5:b3aa0a49e21f | 52 | |
Alkorin | 5:b3aa0a49e21f | 53 | // Macro tools |
Alkorin | 5:b3aa0a49e21f | 54 | #define TOKENPASTE(x, y) x ## y |
Alkorin | 5:b3aa0a49e21f | 55 | #define TOKENPASTE2(x, y) TOKENPASTE(x, y) |
Alkorin | 5:b3aa0a49e21f | 56 | #define TOKENPASTE3(x, y, z) TOKENPASTE(TOKENPASTE(x, y), z) |
Alkorin | 5:b3aa0a49e21f | 57 | |
Alkorin | 0:aa3c3d1a5918 | 58 | #endif |