Finish m9s12 GPIO support
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3318 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
92257eebbf
commit
8cdb7c7e71
@ -315,6 +315,13 @@ HCS12/DEMO9S12NEC64-specific Configuration Options
|
|||||||
the 100 second delay then adjust CONFIG_ARCH_LOOPSPERMSEC until
|
the 100 second delay then adjust CONFIG_ARCH_LOOPSPERMSEC until
|
||||||
the delay actually is 100 seconds.
|
the delay actually is 100 seconds.
|
||||||
|
|
||||||
|
GPIO Interrupts
|
||||||
|
|
||||||
|
CONFIG_GPIO_IRQ - Enable general support for GPIO IRQs
|
||||||
|
CONFIG_HCS12_PORTG_INTS - Enable PortG IRQs
|
||||||
|
CONFIG_HCS12_PORTH_INTS - Enable PortH IRQs
|
||||||
|
CONFIG_HCS12_PORTJ_INTS - Enable PortJ IRQs
|
||||||
|
|
||||||
HCS12 build options:
|
HCS12 build options:
|
||||||
|
|
||||||
CONFIG_HCS12_SERIALMON - Indicates that the target systems uses
|
CONFIG_HCS12_SERIALMON - Indicates that the target systems uses
|
||||||
|
@ -422,6 +422,13 @@ HCS12/NE64BADGE-specific Configuration Options
|
|||||||
the 100 second delay then adjust CONFIG_ARCH_LOOPSPERMSEC until
|
the 100 second delay then adjust CONFIG_ARCH_LOOPSPERMSEC until
|
||||||
the delay actually is 100 seconds.
|
the delay actually is 100 seconds.
|
||||||
|
|
||||||
|
GPIO Interrupts
|
||||||
|
|
||||||
|
CONFIG_GPIO_IRQ - Enable general support for GPIO IRQs
|
||||||
|
CONFIG_HCS12_PORTG_INTS - Enable PortG IRQs
|
||||||
|
CONFIG_HCS12_PORTH_INTS - Enable PortH IRQs
|
||||||
|
CONFIG_HCS12_PORTJ_INTS - Enable PortJ IRQs
|
||||||
|
|
||||||
HCS12 build options:
|
HCS12 build options:
|
||||||
|
|
||||||
CONFIG_HCS12_SERIALMON - Indicates that the target systems uses
|
CONFIG_HCS12_SERIALMON - Indicates that the target systems uses
|
||||||
|
@ -79,17 +79,25 @@
|
|||||||
|
|
||||||
/* The NE64 Badge board has 2 red LEDs that we will encode as: */
|
/* The NE64 Badge board has 2 red LEDs that we will encode as: */
|
||||||
|
|
||||||
#define LED_STARTED 1 /* LED1 */
|
/* LED1 LED2 */
|
||||||
#define LED_HEAPALLOCATE 1 /* LED1 */
|
#define LED_STARTED 0 /* OFF OFF = Still initializing */
|
||||||
#define LED_IRQSENABLED 1 /* LED1 */
|
#define LED_HEAPALLOCATE 0 /* OFF OFF = Still initializing */
|
||||||
#define LED_STACKCREATED 1 /* LED1 */
|
#define LED_IRQSENABLED 0 /* OFF OFF = Still initializing */
|
||||||
#define LED_INIRQ 2 /* LED1 + LED2 */
|
#define LED_STACKCREATED 1 /* ON OFF = Initialization complete */
|
||||||
#define LED_SIGNAL 2 /* LED1 + LED2 */
|
#define LED_INIRQ 2 /* NC ON = In an interrupt handler */
|
||||||
#define LED_ASSERTION 2 /* LED1 + LED2 */
|
#define LED_SIGNAL 2 /* NC ON = In a signal handler */
|
||||||
#define LED_PANIC 7 /* LED2 + N/C */
|
#define LED_ASSERTION 2 /* NC ON = In an assertion */
|
||||||
|
#define LED_PANIC 2 /* NC ON = Oops! We crashed. (flashing) */
|
||||||
|
|
||||||
/* Button definitions ***************************************************************/
|
/* Button definitions ***************************************************************/
|
||||||
|
|
||||||
|
/* The NE64 badge has 2 switches, one labed SW1 and the other SW2 on the board (but
|
||||||
|
* referred to as button1 and button2 in some documentation)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define BUTTON1 1 /* Bit 0: SW1 button is depressed */
|
||||||
|
#define BUTTON2 2 /* Bit 1: SW2 button is depressed */
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
@ -93,6 +93,17 @@ CONFIG_ARCH_BUTTONS=n
|
|||||||
CONFIG_ARCH_CALIBRATION=n
|
CONFIG_ARCH_CALIBRATION=n
|
||||||
CONFIG_ARCH_DMA=n
|
CONFIG_ARCH_DMA=n
|
||||||
|
|
||||||
|
#
|
||||||
|
# CONFIG_GPIO_IRQ - Enable general support for GPIO IRQs
|
||||||
|
# CONFIG_HCS12_PORTG_INTS - Enable PortG IRQs
|
||||||
|
# CONFIG_HCS12_PORTH_INTS - Enable PortH IRQs
|
||||||
|
# CONFIG_HCS12_PORTJ_INTS - Enable PortJ IRQs
|
||||||
|
#
|
||||||
|
CONFIG_GPIO_IRQ=n
|
||||||
|
CONFIG_HCS12_PORTG_INTS=n
|
||||||
|
CONFIG_HCS12_PORTH_INTS=n
|
||||||
|
CONFIG_HCS12_PORTJ_INTS=n
|
||||||
|
|
||||||
#
|
#
|
||||||
# HCS12 build options:
|
# HCS12 build options:
|
||||||
#
|
#
|
||||||
|
@ -44,6 +44,8 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <nuttx/compiler.h>
|
#include <nuttx/compiler.h>
|
||||||
|
|
||||||
|
#include "m9s12_internal.h"
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Definitions
|
* Definitions
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
@ -93,8 +95,11 @@
|
|||||||
* 40 PE5/IPIPE0/MODA J3 MODA " " " " "" " "
|
* 40 PE5/IPIPE0/MODA J3 MODA " " " " "" " "
|
||||||
* 39 PE6/IPIPE1/MODB J3 MODB " " " " "" " "
|
* 39 PE6/IPIPE1/MODB J3 MODB " " " " "" " "
|
||||||
* 38 PE7/NOACC/XCLKS_B pulled low pulled low
|
* 38 PE7/NOACC/XCLKS_B pulled low pulled low
|
||||||
*
|
*/
|
||||||
* 97 PK0/XADR14 N/C N/C
|
|
||||||
|
#define NE64BADGE_BUTTON1 (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT_E | GPIO_PIN_0)
|
||||||
|
|
||||||
|
/* 97 PK0/XADR14 N/C N/C
|
||||||
* 98 PK1/XADR15 N/C N/C
|
* 98 PK1/XADR15 N/C N/C
|
||||||
* 99 PK2/XADR16 N/C N/C
|
* 99 PK2/XADR16 N/C N/C
|
||||||
* 100 PK3/XADR17 N/C N/C
|
* 100 PK3/XADR17 N/C N/C
|
||||||
@ -135,15 +140,22 @@
|
|||||||
* 3 PH4/TXCLK/KWH4 BUTTON2 SW2
|
* 3 PH4/TXCLK/KWH4 BUTTON2 SW2
|
||||||
* 2 PH5/TXDV/KWH5 J5 XBEE_LOAD_H Not used on board
|
* 2 PH5/TXDV/KWH5 J5 XBEE_LOAD_H Not used on board
|
||||||
* 1 PH6/TXER/KWH6 J4 XBEE_LOAD_L Not used on board
|
* 1 PH6/TXER/KWH6 J4 XBEE_LOAD_L Not used on board
|
||||||
*
|
*/
|
||||||
* 8 PJ0/MDC/KWJ0 LED1 D21, red
|
|
||||||
|
#define NE64BADGE_BUTTON2 (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT_H | GPIO_PIN_4)
|
||||||
|
|
||||||
|
/* 8 PJ0/MDC/KWJ0 LED1 D21, red
|
||||||
* 9 PJ1/MDIO/KWJ1 LED2 D22, red
|
* 9 PJ1/MDIO/KWJ1 LED2 D22, red
|
||||||
* 20 PJ2/CRS/KWJ2 J3 SPI_CS Not used on board
|
* 20 PJ2/CRS/KWJ2 J3 SPI_CS Not used on board
|
||||||
* 21 PJ3/COL/KWJ3 N/C
|
* 21 PJ3/COL/KWJ3 N/C
|
||||||
* 112 PJ6/SDA/KWJ6 J3 I2C_DATA Not used on board
|
* 112 PJ6/SDA/KWJ6 J3 I2C_DATA Not used on board
|
||||||
* 111 PJ7/SCL/KWJ7 J3 I2C_CLOCK " " " " "" " "
|
* 111 PJ7/SCL/KWJ7 J3 I2C_CLOCK " " " " "" " "
|
||||||
*
|
*/
|
||||||
* 51 PL6/TXER/KWL6 N/C N/C
|
|
||||||
|
#define NE64BADGE_LED1 (GPIO_OUTPUT | GPIO_OUTPUT_HIGH | GPIO_PORT_J | GPIO_PIN_0)
|
||||||
|
#define NE64BADGE_LED2 (GPIO_OUTPUT | GPIO_OUTPUT_HIGH | GPIO_PORT_J | GPIO_PIN_1)
|
||||||
|
|
||||||
|
/* 51 PL6/TXER/KWL6 N/C N/C
|
||||||
* 52 PL5/TXDV/KWL5 N/C N/C
|
* 52 PL5/TXDV/KWL5 N/C N/C
|
||||||
* 58 PL4/COLLED Collision LED red
|
* 58 PL4/COLLED Collision LED red
|
||||||
* 59 PL3/DUPLED Full Duplex LED yellow
|
* 59 PL3/DUPLED Full Duplex LED yellow
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* configs/ne64badge/src/up_leds.c
|
* configs/ne64badge/src/up_buttons.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
@ -50,6 +50,34 @@
|
|||||||
* Definitions
|
* Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* Enables debug output from this file (needs CONFIG_DEBUG with
|
||||||
|
* CONFIG_DEBUG_VERBOSE too)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#undef BUTTON_DEBUG /* Define to enable debug */
|
||||||
|
#undef BUTTON_VERBOSE /* Define to enable verbose debug */
|
||||||
|
|
||||||
|
#ifdef BUTTON_DEBUG
|
||||||
|
# define btndbg lldbg
|
||||||
|
# ifdef BUTTON_VERBOSE
|
||||||
|
# define btnvdbg lldbg
|
||||||
|
# else
|
||||||
|
# define btnvdbg(x...)
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# undef BUTTON_VERBOSE
|
||||||
|
# define btndbg(x...)
|
||||||
|
# define btnvdbg(x...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Dump GPIO registers */
|
||||||
|
|
||||||
|
#ifdef BUTTON_VERBOSE
|
||||||
|
# define btn_dumpgpio(m) m9s12_dumpgpio(m)
|
||||||
|
#else
|
||||||
|
# define btn_dumpgpio(m)
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -68,6 +96,14 @@
|
|||||||
|
|
||||||
void up_buttoninit(void)
|
void up_buttoninit(void)
|
||||||
{
|
{
|
||||||
|
/* Configure all button GPIO lines */
|
||||||
|
|
||||||
|
btn_dumpgpio("up_buttoninit() Entry)");
|
||||||
|
|
||||||
|
hcs12_configgpio(NE64BADGE_BUTTON1);
|
||||||
|
hcs12_configgpio(NE64BADGE_BUTTON2);
|
||||||
|
|
||||||
|
btn_dumpgpio("up_buttoninit() Exit");
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -76,7 +112,19 @@ void up_buttoninit(void)
|
|||||||
|
|
||||||
uint8_t up_buttons(void)
|
uint8_t up_buttons(void)
|
||||||
{
|
{
|
||||||
return 0;
|
uint8_t ret = 0;
|
||||||
|
|
||||||
|
if (hcs12_gpioread(NE64BADGE_BUTTON1))
|
||||||
|
{
|
||||||
|
ret |= BUTTON1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hcs12_gpioread(NE64BADGE_BUTTON2))
|
||||||
|
{
|
||||||
|
ret |= BUTTON2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_ARCH_BUTTONS */
|
#endif /* CONFIG_ARCH_BUTTONS */
|
||||||
|
@ -46,6 +46,8 @@
|
|||||||
|
|
||||||
#include "ne64badge_internal.h"
|
#include "ne64badge_internal.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_LEDS
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -55,15 +57,29 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#undef LED_DEBUG /* Define to enable debug */
|
#undef LED_DEBUG /* Define to enable debug */
|
||||||
|
#undef LED_VERBOSE /* Define to enable verbose debug */
|
||||||
|
|
||||||
#ifdef LED_DEBUG
|
#ifdef LED_DEBUG
|
||||||
# define leddbg lldbg
|
# define leddbg lldbg
|
||||||
# define ledvdbg llvdbg
|
# ifdef LED_VERBOSE
|
||||||
|
# define ledvdbg lldbg
|
||||||
# else
|
# else
|
||||||
|
# define ledvdbg(x...)
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# undef LED_VERBOSE
|
||||||
# define leddbg(x...)
|
# define leddbg(x...)
|
||||||
# define ledvdbg(x...)
|
# define ledvdbg(x...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Dump GPIO registers */
|
||||||
|
|
||||||
|
#ifdef LED_VERBOSE
|
||||||
|
# define led_dumpgpio(m) m9s12_dumpgpio(m)
|
||||||
|
#else
|
||||||
|
# define led_dumpgpio(m)
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -84,9 +100,16 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_LEDS
|
|
||||||
void up_ledinit(void)
|
void up_ledinit(void)
|
||||||
{
|
{
|
||||||
|
/* Configure all LED GPIO lines */
|
||||||
|
|
||||||
|
led_dumpgpio("up_ledinit() Entry)");
|
||||||
|
|
||||||
|
hcs12_configgpio(NE64BADGE_LED1);
|
||||||
|
hcs12_configgpio(NE64BADGE_LED2);
|
||||||
|
|
||||||
|
led_dumpgpio("up_ledinit() Exit");
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -95,6 +118,23 @@ void up_ledinit(void)
|
|||||||
|
|
||||||
void up_ledon(int led)
|
void up_ledon(int led)
|
||||||
{
|
{
|
||||||
|
switch (led)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case 0 : /* STARTED, HEAPALLOCATE, IRQSENABLED */
|
||||||
|
hcs12_gpiowrite(NE64BADGE_LED1, true);
|
||||||
|
hcs12_gpiowrite(NE64BADGE_LED2, true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1 : /* STACKCREATED */
|
||||||
|
hcs12_gpiowrite(NE64BADGE_LED1, false);
|
||||||
|
hcs12_gpiowrite(NE64BADGE_LED2, true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2 : /* INIRQ, SIGNAL, ASSERTION, PANIC */
|
||||||
|
hcs12_gpiowrite(NE64BADGE_LED2, false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -103,6 +143,16 @@ void up_ledon(int led)
|
|||||||
|
|
||||||
void up_ledoff(int led)
|
void up_ledoff(int led)
|
||||||
{
|
{
|
||||||
|
switch (led)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case 0 : /* STARTED, HEAPALLOCATE, IRQSENABLED */
|
||||||
|
case 1 : /* STACKCREATED */
|
||||||
|
hcs12_gpiowrite(NE64BADGE_LED1, true);
|
||||||
|
case 2 : /* INIRQ, SIGNAL, ASSERTION, PANIC */
|
||||||
|
hcs12_gpiowrite(NE64BADGE_LED2, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_ARCH_LEDS */
|
#endif /* CONFIG_ARCH_LEDS */
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* configs/stm3210e-eval/src/up_leds.c
|
* configs/stm3210e-eval/src/up_buttons.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
Loading…
Reference in New Issue
Block a user