# SFBHWPinsBoard.h

Go to the documentation of this file.

    00001 /*                                              -*- mode:C++; fill-column:100 -*-
    00002   SFBHWPinsBoard.h Board-specific pin function definitions
    00003   Copyright (C) 2008 The Regents of the University of New Mexico.  All rights reserved.
    00004
    00005   This library is free software; you can redistribute it and/or
    00006   modify it under the terms of the GNU Lesser General Public
    00007   License as published by the Free Software Foundation; either
    00008   version 2.1 of the License, or (at your option) any later version.
    00009
    00010   This library is distributed in the hope that it will be useful,
    00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013   Lesser General Public License for more details.
    00014
    00015   You should have received a copy of the GNU General Public License
    00016   along with this library; if not, write to the Free Software
    00017   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
    00018   USA
    00019
    00020   $Id$
    00021 */
    00022
    00030 #ifdef SFBHWPINSHOST_H
    00031 #error SFBHWPinsBoard.h and SFBHWPinsHost.h must not be #included together!
    00032 #endif
    00033
    00034 #ifndef SFBHWPINSBOARD_H
    00035 #define SFBHWPINSBOARD_H
    00036
    00037 #include "lpc/fio.h"
    00038
    00039 #ifdef __cplusplus
    00040 extern "C" {
    00041 #endif
    00042
    00043 /* Fast pin access macros. \cond */
    00044
    00045 #define SFB_PORT_IN_MAP(offset, port) (*((volatile u32 *)(((FIO_BASE_ADDR)+(offset))+(port)*0x20)))
    00046 #define SFB_PORT_DIR_REGISTER(port)  SFB_PORT_IN_MAP(0x00,port)
    00047 #define SFB_PORT_MASK_REGISTER(port) SFB_PORT_IN_MAP(0x10,port)
    00048 #define SFB_PORT_PIN_REGISTER(port)  SFB_PORT_IN_MAP(0x14,port)
    00049 #define SFB_PORT_SET_REGISTER(port)  SFB_PORT_IN_MAP(0x18,port)
    00050 #define SFB_PORT_CLR_REGISTER(port)  SFB_PORT_IN_MAP(0x1C,port)
    00051
    00052 #define SFB_PORT_PINMODE_REGISTER(offset) \
    00053   (*((volatile u32 *)((PINMODE_BASE_ADDR)+(offset))))
    00054
    00055 #define SFB_PINSEL_REGISTER(port,pinNumber) \
    00056   (*((volatile u32 *)((PINSEL_BASE_ADDR)+((port)*8)+(pinNumber>15?4:0))))
    00057
    00058 #define SFB_PORT_GET_BIT_MASK(port,mask) (SFB_PORT_PIN_REGISTER(port)&(mask))
    00059
    00060 #define SFB_PORT_SET_BIT_MASK(port,mask) (SFB_PORT_SET_REGISTER(port) = (mask))
    00061 #define SFB_PORT_CLR_BIT_MASK(port,mask) (SFB_PORT_CLR_REGISTER(port) = (mask))
    00062 #define SFB_PORT_WRITE_BIT_MASK(port,mask,value) \
    00063   ((value==LOW)?SFB_PORT_CLR_BIT_MASK(port,mask):SFB_PORT_SET_BIT_MASK(port,mask))
    00064
    00065 #define LED_GREEN_MASK    (1UL<<0)
    00066 #define LED_RED_MASK      (1UL<<1)
    00067 #define LED_BLUE_MASK     (1UL<<2)
    00068
    00069 #define REFLEX_RGB_RED_ON (FIO2CLR = LED_RED_MASK)
    00070 #define REFLEX_RGB_RED_OFF (FIO2SET = LED_RED_MASK)
    00071 #define REFLEX_RGB_GREEN_ON (FIO2CLR = LED_GREEN_MASK)
    00072 #define REFLEX_RGB_GREEN_OFF (FIO2SET = LED_GREEN_MASK)
    00073 #define REFLEX_RGB_BLUE_ON (FIO2CLR = LED_BLUE_MASK)
    00074 #define REFLEX_RGB_BLUE_OFF (FIO2SET = LED_BLUE_MASK)
    00075
    00076 extern void setPinSelFunction(u32 port,u32 pinNumber,u32 function);
    00077
    00083 extern void reenterBootloader() __attribute__ ((noreturn));
    00084
    00088 extern void reenterBrainstem() __attribute__ ((noreturn));
    00089
    00091 extern void hwpins_startup_initialization();
    00092
    00093 /* Low-level last ditch routine to set the rbg leds, bypassing (and
    00094    thereby breaking) all the normal pin management stuff.  So don't
    00095    use this unless the situation is dire enough that you don't case
    00096    about that. */
    00097 extern void debugRGB(int rgbBits, int wait);
    00101 extern void _dieOnBoard_(u32 blinkCode, const char * file, int lineno) __attribute__ ((noreturn));
    00102
    00103 #ifdef __cplusplus
    00104 }
    00105 #endif
    00106
    00107 #endif  /* SFBHWPINSBOARD_H */