| 1 |
221 |
olivier.gi |
/*===========================================================================*/
|
| 2 |
|
|
/* Copyright (C) 2001 Authors */
|
| 3 |
|
|
/* */
|
| 4 |
|
|
/* This source file may be used and distributed without restriction provided */
|
| 5 |
|
|
/* that this copyright statement is not removed from the file and that any */
|
| 6 |
|
|
/* derivative work contains the original copyright notice and the associated */
|
| 7 |
|
|
/* disclaimer. */
|
| 8 |
|
|
/* */
|
| 9 |
|
|
/* This source file is free software; you can redistribute it and/or modify */
|
| 10 |
|
|
/* it under the terms of the GNU Lesser General Public License as published */
|
| 11 |
|
|
/* by the Free Software Foundation; either version 2.1 of the License, or */
|
| 12 |
|
|
/* (at your option) any later version. */
|
| 13 |
|
|
/* */
|
| 14 |
|
|
/* This source is distributed in the hope that it will be useful, but WITHOUT*/
|
| 15 |
|
|
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
|
| 16 |
|
|
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
|
| 17 |
|
|
/* License for more details. */
|
| 18 |
|
|
/* */
|
| 19 |
|
|
/* You should have received a copy of the GNU Lesser General Public License */
|
| 20 |
|
|
/* along with this source; if not, write to the Free Software Foundation, */
|
| 21 |
|
|
/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
| 22 |
|
|
/* */
|
| 23 |
|
|
/*===========================================================================*/
|
| 24 |
|
|
/* OMSP_SYSTEM HEADER FILE */
|
| 25 |
|
|
/*---------------------------------------------------------------------------*/
|
| 26 |
|
|
/* */
|
| 27 |
|
|
/* Author(s): */
|
| 28 |
|
|
/* - Olivier Girard, olgirard@gmail.com */
|
| 29 |
|
|
/* */
|
| 30 |
|
|
/*---------------------------------------------------------------------------*/
|
| 31 |
|
|
/* $Rev: 19 $ */
|
| 32 |
|
|
/* $LastChangedBy: olivier.girard $ */
|
| 33 |
|
|
/* $LastChangedDate: 2009-08-04 23:47:15 +0200 (Tue, 04 Aug 2009) $ */
|
| 34 |
|
|
/*===========================================================================*/
|
| 35 |
|
|
|
| 36 |
|
|
#include <in430.h>
|
| 37 |
|
|
|
| 38 |
|
|
//=============================================================================
|
| 39 |
|
|
// STATUS REGISTER BITS
|
| 40 |
|
|
//=============================================================================
|
| 41 |
|
|
|
| 42 |
|
|
// Flags
|
| 43 |
|
|
#define C (0x0001)
|
| 44 |
|
|
#define Z (0x0002)
|
| 45 |
|
|
#define N (0x0004)
|
| 46 |
|
|
#define V (0x0100)
|
| 47 |
|
|
#define GIE (0x0008)
|
| 48 |
|
|
#define CPUOFF (0x0010)
|
| 49 |
|
|
#define OSCOFF (0x0020)
|
| 50 |
|
|
#define SCG0 (0x0040)
|
| 51 |
|
|
#define SCG1 (0x0080)
|
| 52 |
|
|
|
| 53 |
|
|
// Low Power Modes coded with Bits 4-7 in SR
|
| 54 |
|
|
#define LPM0_bits (CPUOFF)
|
| 55 |
|
|
#define LPM1_bits (SCG0+CPUOFF)
|
| 56 |
|
|
#define LPM2_bits (SCG1+CPUOFF)
|
| 57 |
|
|
#define LPM3_bits (SCG1+SCG0+CPUOFF)
|
| 58 |
|
|
#define LPM4_bits (SCG1+SCG0+OSCOFF+CPUOFF)
|
| 59 |
|
|
|
| 60 |
|
|
#define LPM0 _BIS_SR(LPM0_bits) // Enter Low Power Mode 0
|
| 61 |
|
|
#define LPM0_EXIT _BIC_SR_IRQ(LPM0_bits) // Exit Low Power Mode 0
|
| 62 |
|
|
#define LPM1 _BIS_SR(LPM1_bits) // Enter Low Power Mode 1
|
| 63 |
|
|
#define LPM1_EXIT _BIC_SR_IRQ(LPM1_bits) // Exit Low Power Mode 1
|
| 64 |
|
|
#define LPM2 _BIS_SR(LPM2_bits) // Enter Low Power Mode 2
|
| 65 |
|
|
#define LPM2_EXIT _BIC_SR_IRQ(LPM2_bits) // Exit Low Power Mode 2
|
| 66 |
|
|
#define LPM3 _BIS_SR(LPM3_bits) // Enter Low Power Mode 3
|
| 67 |
|
|
#define LPM3_EXIT _BIC_SR_IRQ(LPM3_bits) // Exit Low Power Mode 3
|
| 68 |
|
|
#define LPM4 _BIS_SR(LPM4_bits) // Enter Low Power Mode 4
|
| 69 |
|
|
#define LPM4_EXIT _BIC_SR_IRQ(LPM4_bits) // Exit Low Power Mode 4
|
| 70 |
|
|
|
| 71 |
|
|
|
| 72 |
|
|
//=============================================================================
|
| 73 |
|
|
// PERIPHERALS REGISTER DEFINITIONS
|
| 74 |
|
|
//=============================================================================
|
| 75 |
|
|
|
| 76 |
|
|
//----------------------------------------------------------
|
| 77 |
|
|
// SPECIAL FUNCTION REGISTERS
|
| 78 |
|
|
//----------------------------------------------------------
|
| 79 |
|
|
#define IE1_set_wdtie() __asm__ __volatile__ ("bis.b #0x01, &0x0000")
|
| 80 |
|
|
//#define IE1 (*(volatile unsigned char *) 0x0000)
|
| 81 |
|
|
#define IFG1 (*(volatile unsigned char *) 0x0002)
|
| 82 |
|
|
|
| 83 |
|
|
#define CPU_ID_LO (*(volatile unsigned int *) 0x0004)
|
| 84 |
|
|
#define CPU_ID_HI (*(volatile unsigned int *) 0x0006)
|
| 85 |
|
|
#define CPU_NR (*(volatile unsigned int *) 0x0008)
|
| 86 |
|
|
|
| 87 |
|
|
|
| 88 |
|
|
//----------------------------------------------------------
|
| 89 |
|
|
// KEY / SW / LEDs
|
| 90 |
|
|
//----------------------------------------------------------
|
| 91 |
|
|
#define LED_CTRL (*(volatile unsigned char *) 0x0090)
|
| 92 |
|
|
#define KEY_SW_VAL (*(volatile unsigned char *) 0x0091)
|
| 93 |
|
|
#define KEY_SW_IRQ_EN (*(volatile unsigned char *) 0x0092)
|
| 94 |
|
|
#define KEY_SW_IRQ_EDGE (*(volatile unsigned char *) 0x0093)
|
| 95 |
|
|
#define KEY_SW_IRQ_VAL (*(volatile unsigned char *) 0x0094)
|
| 96 |
|
|
|
| 97 |
|
|
|
| 98 |
|
|
//----------------------------------------------------------
|
| 99 |
|
|
// BASIC CLOCK MODULE
|
| 100 |
|
|
//----------------------------------------------------------
|
| 101 |
|
|
#define DCOCTL (*(volatile unsigned char *) 0x0056)
|
| 102 |
|
|
#define BCSCTL1 (*(volatile unsigned char *) 0x0057)
|
| 103 |
|
|
#define BCSCTL2 (*(volatile unsigned char *) 0x0058)
|
| 104 |
|
|
|
| 105 |
|
|
|
| 106 |
|
|
//----------------------------------------------------------
|
| 107 |
|
|
// WATCHDOG TIMER
|
| 108 |
|
|
//----------------------------------------------------------
|
| 109 |
|
|
|
| 110 |
|
|
// Addresses
|
| 111 |
|
|
#define WDTCTL (*(volatile unsigned int *) 0x0120)
|
| 112 |
|
|
|
| 113 |
|
|
// Bit masks
|
| 114 |
|
|
#define WDTIS0 (0x0001)
|
| 115 |
|
|
#define WDTIS1 (0x0002)
|
| 116 |
|
|
#define WDTSSEL (0x0004)
|
| 117 |
|
|
#define WDTCNTCL (0x0008)
|
| 118 |
|
|
#define WDTTMSEL (0x0010)
|
| 119 |
|
|
#define WDTNMI (0x0020)
|
| 120 |
|
|
#define WDTNMIES (0x0040)
|
| 121 |
|
|
#define WDTHOLD (0x0080)
|
| 122 |
|
|
#define WDTPW (0x5A00)
|
| 123 |
|
|
|
| 124 |
|
|
|
| 125 |
|
|
//----------------------------------------------------------
|
| 126 |
|
|
// HARDWARE MULTIPLIER
|
| 127 |
|
|
//----------------------------------------------------------
|
| 128 |
|
|
#define OP1_MPY (*(volatile unsigned int *) 0x0130)
|
| 129 |
|
|
#define OP1_MPYS (*(volatile unsigned int *) 0x0132)
|
| 130 |
|
|
#define OP1_MAC (*(volatile unsigned int *) 0x0134)
|
| 131 |
|
|
#define OP1_MACS (*(volatile unsigned int *) 0x0136)
|
| 132 |
|
|
#define OP2 (*(volatile unsigned int *) 0x0138)
|
| 133 |
|
|
|
| 134 |
|
|
#define RESLO (*(volatile unsigned int *) 0x013A)
|
| 135 |
|
|
#define RESHI (*(volatile unsigned int *) 0x013C)
|
| 136 |
|
|
#define SUMEXT (*(volatile unsigned int *) 0x013E)
|
| 137 |
|
|
|
| 138 |
|
|
|
| 139 |
|
|
//=============================================================================
|
| 140 |
|
|
// INTERRUPT VECTORS
|
| 141 |
|
|
//=============================================================================
|
| 142 |
|
|
#define interrupt(x) void __attribute__((interrupt (x)))
|
| 143 |
|
|
#define wakeup __attribute__((wakeup))
|
| 144 |
|
|
#define eint() __eint()
|
| 145 |
|
|
#define dint() __dint()
|
| 146 |
|
|
|
| 147 |
|
|
// Vector definition for RedHat/TI toolchain
|
| 148 |
|
|
#ifdef PFX_MSP430_ELF
|
| 149 |
|
|
#define RESET_VECTOR ("reset") // Vector 15 (0xFFFE) - Reset - [Highest Priority]
|
| 150 |
|
|
#define NMI_VECTOR (15) // Vector 14 (0xFFFC) - Non-maskable -
|
| 151 |
|
|
#define UNUSED_13_VECTOR (14) // Vector 13 (0xFFFA) - -
|
| 152 |
|
|
#define UNUSED_12_VECTOR (13) // Vector 12 (0xFFF8) - -
|
| 153 |
|
|
#define UNUSED_11_VECTOR (12) // Vector 11 (0xFFF6) - -
|
| 154 |
|
|
#define WDT_VECTOR (11) // Vector 10 (0xFFF4) - Watchdog Timer -
|
| 155 |
|
|
#define TIMERA0_VECTOR (10) // Vector 9 (0xFFF2) - Timer A CC0 -
|
| 156 |
|
|
#define TIMERA1_VECTOR (9) // Vector 8 (0xFFF0) - Timer A CC1-2, TA -
|
| 157 |
|
|
#define UNUSED_07_VECTOR (8) // Vector 7 (0xFFEE) - -
|
| 158 |
|
|
#define UNUSED_06_VECTOR (7) // Vector 6 (0xFFEC) - -
|
| 159 |
|
|
#define UNUSED_05_VECTOR (6) // Vector 5 (0xFFEA) - -
|
| 160 |
|
|
#define UNUSED_04_VECTOR (5) // Vector 4 (0xFFE8) - -
|
| 161 |
|
|
#define UNUSED_03_VECTOR (4) // Vector 3 (0xFFE6) - -
|
| 162 |
|
|
#define PORT1_VECTOR (3) // Vector 2 (0xFFE4) - Port 1 -
|
| 163 |
|
|
#define UNUSED_01_VECTOR (2) // Vector 1 (0xFFE2) - -
|
| 164 |
|
|
#define UNUSED_00_VECTOR (1) // Vector 0 (0xFFE0) - - [Lowest Priority]
|
| 165 |
|
|
|
| 166 |
|
|
// Vector definition for MSPGCC toolchain
|
| 167 |
|
|
#else
|
| 168 |
|
|
#define RESET_VECTOR (0x001E) // Vector 15 (0xFFFE) - Reset - [Highest Priority]
|
| 169 |
|
|
#define NMI_VECTOR (0x001C) // Vector 14 (0xFFFC) - Non-maskable -
|
| 170 |
|
|
#define UNUSED_13_VECTOR (0x001A) // Vector 13 (0xFFFA) - -
|
| 171 |
|
|
#define UNUSED_12_VECTOR (0x0018) // Vector 12 (0xFFF8) - -
|
| 172 |
|
|
#define UNUSED_11_VECTOR (0x0016) // Vector 11 (0xFFF6) - -
|
| 173 |
|
|
#define WDT_VECTOR (0x0014) // Vector 10 (0xFFF4) - Watchdog Timer -
|
| 174 |
|
|
#define TIMERA0_VECTOR (0x0012) // Vector 9 (0xFFF2) - Timer A CC0 -
|
| 175 |
|
|
#define TIMERA1_VECTOR (0x0010) // Vector 8 (0xFFF0) - Timer A CC1-2, TA -
|
| 176 |
|
|
#define UNUSED_07_VECTOR (0x000E) // Vector 7 (0xFFEE) - -
|
| 177 |
|
|
#define UNUSED_06_VECTOR (0x000C) // Vector 6 (0xFFEC) - -
|
| 178 |
|
|
#define UNUSED_05_VECTOR (0x000A) // Vector 5 (0xFFEA) - -
|
| 179 |
|
|
#define UNUSED_04_VECTOR (0x0008) // Vector 4 (0xFFE8) - -
|
| 180 |
|
|
#define UNUSED_03_VECTOR (0x0006) // Vector 3 (0xFFE6) - -
|
| 181 |
|
|
#define PORT1_VECTOR (0x0004) // Vector 2 (0xFFE4) - Port 1 -
|
| 182 |
|
|
#define UNUSED_01_VECTOR (0x0002) // Vector 1 (0xFFE2) - -
|
| 183 |
|
|
#define UNUSED_00_VECTOR (0x0000) // Vector 0 (0xFFE0) - - [Lowest Priority]
|
| 184 |
|
|
#endif
|