SimpleLib_03272011
Embed:
(wiki syntax)
Show/hide line numbers
mbed_globals.h
00001 /* 00002 * Copyright or � or Copr. 2010, Thomas SOETE 00003 * 00004 * Author e-mail: thomas@soete.org 00005 * Library website : http://mbed.org/users/Alkorin/libraries/SimpleLib/ 00006 * 00007 * This software is governed by the CeCILL license under French law and 00008 * abiding by the rules of distribution of free software. You can use, 00009 * modify and/ or redistribute the software under the terms of the CeCILL 00010 * license as circulated by CEA, CNRS and INRIA at the following URL 00011 * "http://www.cecill.info". 00012 * 00013 * As a counterpart to the access to the source code and rights to copy, 00014 * modify and redistribute granted by the license, users are provided only 00015 * with a limited warranty and the software's author, the holder of the 00016 * economic rights, and the successive licensors have only limited 00017 * liability. 00018 * 00019 * In this respect, the user's attention is drawn to the risks associated 00020 * with loading, using, modifying and/or developing or reproducing the 00021 * software by the user in light of its specific status of free software, 00022 * that may mean that it is complicated to manipulate, and that also 00023 * therefore means that it is reserved for developers and experienced 00024 * professionals having in-depth computer knowledge. Users are therefore 00025 * encouraged to load and test the software's suitability as regards their 00026 * requirements in conditions enabling the security of their systems and/or 00027 * data to be ensured and, more generally, to use and operate it in the 00028 * same conditions as regards security. 00029 * 00030 * The fact that you are presently reading this means that you have had 00031 * knowledge of the CeCILL license and that you accept its terms. 00032 */ 00033 00034 #ifndef __SIMPLELIB_MBED_GLOBALS_H__ 00035 #define __SIMPLELIB_MBED_GLOBALS_H__ 00036 00037 #include <LPC17xx.h> 00038 00039 /* GLOBALS MACRO */ 00040 #define GET_REGISTER8(reg) *(volatile uint8_t *)(reg) 00041 #define GET_REGISTER16(reg) *(volatile uint16_t *)(reg) 00042 #define GET_REGISTER32(reg) *(volatile uint32_t *)(reg) 00043 00044 #define SET_REGISTER8(reg, val) *(uint8_t *)(reg)=(val) 00045 #define SET_REGISTER16(reg, val) *(uint16_t *)(reg)=(val) 00046 #define SET_REGISTER32(reg, val) *(uint32_t *)(reg)=(val) 00047 00048 // See 34.3.2.5 p740 00049 #define BIT_BANDING_ADDRESS(reg, bit) (((reg) & 0xF0000000) | (0x02000000) | (((reg) & 0x000FFFFF) << 5) | ((bit) << 2)) 00050 #define GET_BIT_ADDRESS(reg, bit) BIT_BANDING_ADDRESS(((uint32_t)&(reg)), (bit)) 00051 #define GET_BIT_VALUE(reg, bit) GET_REGISTER32(GET_BIT_ADDRESS((reg), (bit))) 00052 #define SET_BIT_VALUE(reg, bit, value) SET_REGISTER32(GET_BIT_ADDRESS((reg), (bit)), (value)) 00053 00054 // Macro tools 00055 #define TOKENPASTE(x, y) x ## y 00056 #define TOKENPASTE2(x, y) TOKENPASTE(x, y) 00057 00058 // Extern C 00059 #ifdef __cplusplus 00060 #define EXTERN_C extern "C" 00061 #else 00062 #define EXTERN_C 00063 #endif 00064 00065 // Byte swap macros 00066 #define HTONS(x) (((((unsigned short)(x))>>8) & 0xff) | ((((unsigned short)(x)) & 0xff)<<8)) 00067 #define NTOHS(x) (((((unsigned short)(x))>>8) & 0xff) | ((((unsigned short)(x)) & 0xff)<<8)) 00068 #define HTONL(x) ((((x)>>24) & 0xffL) | (((x)>>8) & 0xff00L) | (((x)<<8) & 0xff0000L) | (((x)<<24) & 0xff000000L)) 00069 #define NTOHL(x) ((((x)>>24) & 0xffL) | (((x)>>8) & 0xff00L) | (((x)<<8) & 0xff0000L) | (((x)<<24) & 0xff000000L)) 00070 00071 00072 /** Constants **/ 00073 // Peripheral Clock Selection register bit values (Table 42, p57) 00074 #define CCLK4 0U 00075 #define CCLK 1U 00076 #define CCLK2 2U 00077 #define CCLK8 3U 00078 00079 #endif
Generated on Fri Jul 15 2022 15:25:50 by
1.7.2