The first video game for the mbed video game console. The code utilizes the SimpleLib package developed by thomas@soete.org. For more information about the project and if you'd like to download the schematics and PCB design visit http://www.mbedgc.com/
mbed_globals.h@0:31cd577d85a4, 2011-07-09 (annotated)
- Committer:
- jp
- Date:
- Sat Jul 09 15:47:27 2011 +0000
- Revision:
- 0:31cd577d85a4
Initial release of Snake for the mbed Game Console.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jp | 0:31cd577d85a4 | 1 | /* |
jp | 0:31cd577d85a4 | 2 | * Copyright or � or Copr. 2010, Thomas SOETE |
jp | 0:31cd577d85a4 | 3 | * |
jp | 0:31cd577d85a4 | 4 | * Author e-mail: thomas@soete.org |
jp | 0:31cd577d85a4 | 5 | * Library website : http://mbed.org/users/Alkorin/libraries/SimpleLib/ |
jp | 0:31cd577d85a4 | 6 | * |
jp | 0:31cd577d85a4 | 7 | * This software is governed by the CeCILL license under French law and |
jp | 0:31cd577d85a4 | 8 | * abiding by the rules of distribution of free software. You can use, |
jp | 0:31cd577d85a4 | 9 | * modify and/ or redistribute the software under the terms of the CeCILL |
jp | 0:31cd577d85a4 | 10 | * license as circulated by CEA, CNRS and INRIA at the following URL |
jp | 0:31cd577d85a4 | 11 | * "http://www.cecill.info". |
jp | 0:31cd577d85a4 | 12 | * |
jp | 0:31cd577d85a4 | 13 | * As a counterpart to the access to the source code and rights to copy, |
jp | 0:31cd577d85a4 | 14 | * modify and redistribute granted by the license, users are provided only |
jp | 0:31cd577d85a4 | 15 | * with a limited warranty and the software's author, the holder of the |
jp | 0:31cd577d85a4 | 16 | * economic rights, and the successive licensors have only limited |
jp | 0:31cd577d85a4 | 17 | * liability. |
jp | 0:31cd577d85a4 | 18 | * |
jp | 0:31cd577d85a4 | 19 | * In this respect, the user's attention is drawn to the risks associated |
jp | 0:31cd577d85a4 | 20 | * with loading, using, modifying and/or developing or reproducing the |
jp | 0:31cd577d85a4 | 21 | * software by the user in light of its specific status of free software, |
jp | 0:31cd577d85a4 | 22 | * that may mean that it is complicated to manipulate, and that also |
jp | 0:31cd577d85a4 | 23 | * therefore means that it is reserved for developers and experienced |
jp | 0:31cd577d85a4 | 24 | * professionals having in-depth computer knowledge. Users are therefore |
jp | 0:31cd577d85a4 | 25 | * encouraged to load and test the software's suitability as regards their |
jp | 0:31cd577d85a4 | 26 | * requirements in conditions enabling the security of their systems and/or |
jp | 0:31cd577d85a4 | 27 | * data to be ensured and, more generally, to use and operate it in the |
jp | 0:31cd577d85a4 | 28 | * same conditions as regards security. |
jp | 0:31cd577d85a4 | 29 | * |
jp | 0:31cd577d85a4 | 30 | * The fact that you are presently reading this means that you have had |
jp | 0:31cd577d85a4 | 31 | * knowledge of the CeCILL license and that you accept its terms. |
jp | 0:31cd577d85a4 | 32 | */ |
jp | 0:31cd577d85a4 | 33 | |
jp | 0:31cd577d85a4 | 34 | #ifndef __SIMPLELIB_MBED_GLOBALS_H__ |
jp | 0:31cd577d85a4 | 35 | #define __SIMPLELIB_MBED_GLOBALS_H__ |
jp | 0:31cd577d85a4 | 36 | |
jp | 0:31cd577d85a4 | 37 | #include <LPC17xx.h> |
jp | 0:31cd577d85a4 | 38 | |
jp | 0:31cd577d85a4 | 39 | /* GLOBALS MACRO */ |
jp | 0:31cd577d85a4 | 40 | #define GET_REGISTER8(reg) *(volatile uint8_t *)(reg) |
jp | 0:31cd577d85a4 | 41 | #define GET_REGISTER16(reg) *(volatile uint16_t *)(reg) |
jp | 0:31cd577d85a4 | 42 | #define GET_REGISTER32(reg) *(volatile uint32_t *)(reg) |
jp | 0:31cd577d85a4 | 43 | |
jp | 0:31cd577d85a4 | 44 | #define SET_REGISTER8(reg, val) *(uint8_t *)(reg)=(val) |
jp | 0:31cd577d85a4 | 45 | #define SET_REGISTER16(reg, val) *(uint16_t *)(reg)=(val) |
jp | 0:31cd577d85a4 | 46 | #define SET_REGISTER32(reg, val) *(uint32_t *)(reg)=(val) |
jp | 0:31cd577d85a4 | 47 | |
jp | 0:31cd577d85a4 | 48 | // See 34.3.2.5 p740 |
jp | 0:31cd577d85a4 | 49 | #define BIT_BANDING_ADDRESS(reg, bit) (((reg) & 0xF0000000) | (0x02000000) | (((reg) & 0x000FFFFF) << 5) | ((bit) << 2)) |
jp | 0:31cd577d85a4 | 50 | #define GET_BIT_ADDRESS(reg, bit) BIT_BANDING_ADDRESS(((uint32_t)&(reg)), (bit)) |
jp | 0:31cd577d85a4 | 51 | #define GET_BIT_VALUE(reg, bit) GET_REGISTER32(GET_BIT_ADDRESS((reg), (bit))) |
jp | 0:31cd577d85a4 | 52 | #define SET_BIT_VALUE(reg, bit, value) SET_REGISTER32(GET_BIT_ADDRESS((reg), (bit)), (value)) |
jp | 0:31cd577d85a4 | 53 | |
jp | 0:31cd577d85a4 | 54 | // Macro tools |
jp | 0:31cd577d85a4 | 55 | #define TOKENPASTE(x, y) x ## y |
jp | 0:31cd577d85a4 | 56 | #define TOKENPASTE2(x, y) TOKENPASTE(x, y) |
jp | 0:31cd577d85a4 | 57 | |
jp | 0:31cd577d85a4 | 58 | // Extern C |
jp | 0:31cd577d85a4 | 59 | #ifdef __cplusplus |
jp | 0:31cd577d85a4 | 60 | #define EXTERN_C extern "C" |
jp | 0:31cd577d85a4 | 61 | #else |
jp | 0:31cd577d85a4 | 62 | #define EXTERN_C |
jp | 0:31cd577d85a4 | 63 | #endif |
jp | 0:31cd577d85a4 | 64 | |
jp | 0:31cd577d85a4 | 65 | // Byte swap macros |
jp | 0:31cd577d85a4 | 66 | #define HTONS(x) (((((unsigned short)(x))>>8) & 0xff) | ((((unsigned short)(x)) & 0xff)<<8)) |
jp | 0:31cd577d85a4 | 67 | #define NTOHS(x) (((((unsigned short)(x))>>8) & 0xff) | ((((unsigned short)(x)) & 0xff)<<8)) |
jp | 0:31cd577d85a4 | 68 | #define HTONL(x) ((((x)>>24) & 0xffL) | (((x)>>8) & 0xff00L) | (((x)<<8) & 0xff0000L) | (((x)<<24) & 0xff000000L)) |
jp | 0:31cd577d85a4 | 69 | #define NTOHL(x) ((((x)>>24) & 0xffL) | (((x)>>8) & 0xff00L) | (((x)<<8) & 0xff0000L) | (((x)<<24) & 0xff000000L)) |
jp | 0:31cd577d85a4 | 70 | |
jp | 0:31cd577d85a4 | 71 | |
jp | 0:31cd577d85a4 | 72 | /** Constants **/ |
jp | 0:31cd577d85a4 | 73 | // Peripheral Clock Selection register bit values (Table 42, p57) |
jp | 0:31cd577d85a4 | 74 | #define CCLK4 0U |
jp | 0:31cd577d85a4 | 75 | #define CCLK 1U |
jp | 0:31cd577d85a4 | 76 | #define CCLK2 2U |
jp | 0:31cd577d85a4 | 77 | #define CCLK8 3U |
jp | 0:31cd577d85a4 | 78 | |
jp | 0:31cd577d85a4 | 79 | #endif |