source: examples-v2/led/led.h @ a26bba5

4.11
Last change on this file since a26bba5 was 3083373, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 6, 2009 at 8:25:58 PM

Initial import of reorganized examples.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 *  LED -- simple LED support
3 *
4 *  $Id$
5 */
6
7#ifndef __LED_h
8#define __LED_h
9
10#define __LONG_LED
11
12#include <stdio.h>
13
14#if defined(mbx860)
15
16#define MBX_LED_REG *((volatile unsigned char *)0xfa100001)
17
18#define LED_ON()  MBX_LED_REG = 0x0F
19#define LED_OFF() MBX_LED_REG = 0x00
20
21#elif defined(icecube)
22
23#include <bsp/mpc5200.h>
24
25#define LED_INIT() \
26  do { \
27    mpc5200.gpiosen |= 0x30000000; \
28    mpc5200.gpiosdd |= 0x30000000; \
29  } while (0)
30
31#define LED_ON() \
32  do { \
33    mpc5200.gpiosdo |= 0x30000000; \
34  } while (0)
35
36#define LED_OFF() \
37  do { \
38    mpc5200.gpiosdo &= ~0x30000000; \
39  } while (0)
40
41#elif defined(MPC8313ERDB)
42
43/* This rotates a single LED off around the back of 8. */
44volatile uint8_t *MPC8313_LED_REG;
45uint8_t MPC8313_LED_Values[] =
46    { 0x01, 0x02, 0x04, 0x08, 0x80, 0x40, 0x20, 0x10};
47uint8_t MPC8313_LED_Count;
48
49#define LED_INIT()  \
50  do { \
51    MPC8313_LED_REG = (uint8_t *) 0xfa000000; \
52    MPC8313_LED_Count = 0; \
53  } while (0)
54
55#define LED_ROTATE()  \
56  do { \
57    *MPC8313_LED_REG = MPC8313_LED_Values[MPC8313_LED_Count]; \
58    /* printk( "v=0x%02x ", MPC8313_LED_Values[MPC8313_LED_Count] ); */ \
59    if ( ++MPC8313_LED_Count == 9 ) \
60      MPC8313_LED_Count = 0; \
61  } while (0)
62
63#define LED_ON() LED_ROTATE()
64#define LED_OFF() LED_ROTATE()
65
66#else
67/* default case is to print */
68
69#define __LED_PRINTING 1
70#define LED_ON()  fputs( "LED ON\n", stderr )
71#define LED_OFF() fputs( "LED OFF\n", stderr )
72
73#endif
74
75#ifndef LED_INIT
76#define LED_INIT()
77#endif
78
79#endif
Note: See TracBrowser for help on using the repository browser.