git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4713 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
12af666276
commit
a8f264a818
|
@ -22,10 +22,17 @@
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
|
|
||||||
#if HAL_USE_PAL || defined(__DOXYGEN__)
|
#if HAL_USE_PAL || defined(__DOXYGEN__)
|
||||||
/* List of the PCR values to be setup initially, the list is terminated by a
|
/* Initial setup of all defined pads, the list is terminated by a {0, 0}.*/
|
||||||
{0, 0}.*/
|
static const spc560p_siul_init_t spc560p_siul_init[] = {
|
||||||
static const spc560p_pcr_init_t spc560p_pcrs_init[] = {
|
{PCR(PD, PD_BUTTON1), PAL_LOW, PAL_MODE_INPUT},
|
||||||
{0, 0}
|
{PCR(PD, PD_BUTTON2), PAL_LOW, PAL_MODE_INPUT},
|
||||||
|
{PCR(PD, PD_BUTTON3), PAL_LOW, PAL_MODE_INPUT},
|
||||||
|
{PCR(PD, PD_BUTTON4), PAL_LOW, PAL_MODE_INPUT},
|
||||||
|
{PCR(PD, PD_LED1), PAL_HIGH, PAL_MODE_OUTPUT_PUSHPULL},
|
||||||
|
{PCR(PD, PD_LED2), PAL_HIGH, PAL_MODE_OUTPUT_PUSHPULL},
|
||||||
|
{PCR(PD, PD_LED3), PAL_HIGH, PAL_MODE_OUTPUT_PUSHPULL},
|
||||||
|
{PCR(PD, PD_LED4), PAL_HIGH, PAL_MODE_OUTPUT_PUSHPULL},
|
||||||
|
{0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Initialization array for the PSMI registers.*/
|
/* Initialization array for the PSMI registers.*/
|
||||||
|
@ -40,8 +47,8 @@ static const uint8_t spc560p_padsels_init[36] = {
|
||||||
*/
|
*/
|
||||||
const PALConfig pal_default_config =
|
const PALConfig pal_default_config =
|
||||||
{
|
{
|
||||||
PAL_MODE_UNCONNECTED,
|
PAL_MODE_UNCONNECTED, /* Default mode for all undefined pads. */
|
||||||
spc560p_pcrs_init,
|
spc560p_siul_init,
|
||||||
spc560p_padsels_init
|
spc560p_padsels_init
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -41,18 +41,20 @@
|
||||||
/*
|
/*
|
||||||
* I/O definitions.
|
* I/O definitions.
|
||||||
*/
|
*/
|
||||||
#define GPIO_SCI_A_TX 89
|
#define PD_BUTTON1 0
|
||||||
#define GPIO_SCI_A_RX 90
|
#define PD_BUTTON2 1
|
||||||
|
#define PD_BUTTON3 2
|
||||||
|
#define PD_BUTTON4 3
|
||||||
|
|
||||||
#define GPIO_BUTTON1 179
|
#define PD_LED1 4
|
||||||
#define GPIO_BUTTON2 181
|
#define PD_LED2 5
|
||||||
#define GPIO_BUTTON3 183
|
#define PD_LED3 6
|
||||||
#define GPIO_BUTTON4 187
|
#define PD_LED4 7
|
||||||
|
|
||||||
#define GPIO_LED1 188
|
/*
|
||||||
#define GPIO_LED2 189
|
* Support macros.
|
||||||
#define GPIO_LED3 190
|
*/
|
||||||
#define GPIO_LED4 191
|
#define PCR(port, pin) (((port) * 16) + (pin))
|
||||||
|
|
||||||
#if !defined(_FROM_ASM_)
|
#if !defined(_FROM_ASM_)
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -94,12 +94,12 @@
|
||||||
/**
|
/**
|
||||||
* @brief Logical low state.
|
* @brief Logical low state.
|
||||||
*/
|
*/
|
||||||
#define PAL_LOW 0
|
#define PAL_LOW 0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Logical high state.
|
* @brief Logical high state.
|
||||||
*/
|
*/
|
||||||
#define PAL_HIGH 1
|
#define PAL_HIGH 1
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -151,7 +151,9 @@ typedef struct {
|
||||||
* @param[in] n bit position within the port
|
* @param[in] n bit position within the port
|
||||||
* @return The bit mask.
|
* @return The bit mask.
|
||||||
*/
|
*/
|
||||||
|
#if !defined(PAL_PORT_BIT) || defined(__DOXYGEN__)
|
||||||
#define PAL_PORT_BIT(n) ((ioportmask_t)(1 << (n)))
|
#define PAL_PORT_BIT(n) ((ioportmask_t)(1 << (n)))
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Bits group mask helper.
|
* @brief Bits group mask helper.
|
||||||
|
@ -160,7 +162,9 @@ typedef struct {
|
||||||
* @param[in] width group width
|
* @param[in] width group width
|
||||||
* @return The group mask.
|
* @return The group mask.
|
||||||
*/
|
*/
|
||||||
|
#if !defined(PAL_GROUP_MASK) || defined(__DOXYGEN__)
|
||||||
#define PAL_GROUP_MASK(width) ((ioportmask_t)(1 << (width)) - 1)
|
#define PAL_GROUP_MASK(width) ((ioportmask_t)(1 << (width)) - 1)
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Data part of a static I/O bus initializer.
|
* @brief Data part of a static I/O bus initializer.
|
||||||
|
|
|
@ -70,8 +70,9 @@ void _pal_lld_init(const PALConfig *config) {
|
||||||
SIU.PCR[i].R = config->default_mode;
|
SIU.PCR[i].R = config->default_mode;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (config->pcrs[i].pcr_value != 0) {
|
while (config->inits[i].pcr_value != 0) {
|
||||||
SIU.PCR[config->pcrs[i].pcr_index].R = config->pcrs[i].pcr_value;
|
SIU.GPDO[config->inits[i].pcr_index].R = config->inits[i].gpdo_value;
|
||||||
|
SIU.PCR[config->inits[i].pcr_index].R = config->inits[i].pcr_value;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,18 +114,18 @@
|
||||||
/**
|
/**
|
||||||
* @brief Width, in bits, of an I/O port.
|
* @brief Width, in bits, of an I/O port.
|
||||||
*/
|
*/
|
||||||
#define PAL_IOPORTS_WIDTH 32
|
#define PAL_IOPORTS_WIDTH 16
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Whole port mask.
|
* @brief Whole port mask.
|
||||||
* @brief This macro specifies all the valid bits into a port.
|
* @brief This macro specifies all the valid bits into a port.
|
||||||
*/
|
*/
|
||||||
#define PAL_WHOLE_PORT ((ioportmask_t)0xFFFFFFFF)
|
#define PAL_WHOLE_PORT ((ioportmask_t)0xFFFF)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Digital I/O port sized unsigned type.
|
* @brief Digital I/O port sized unsigned type.
|
||||||
*/
|
*/
|
||||||
typedef uint32_t ioportmask_t;
|
typedef uint16_t ioportmask_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Digital I/O modes.
|
* @brief Digital I/O modes.
|
||||||
|
@ -141,12 +141,13 @@ typedef uint16_t iomode_t;
|
||||||
typedef uint32_t ioportid_t;
|
typedef uint32_t ioportid_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief PCR register initializer type.
|
* @brief SIUL register initializer type.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t pcr_index;
|
uint8_t pcr_index;
|
||||||
|
uint8_t gpdo_value;
|
||||||
iomode_t pcr_value;
|
iomode_t pcr_value;
|
||||||
} spc560p_pcr_init_t;
|
} spc560p_siul_init_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Generic I/O ports static initializer.
|
* @brief Generic I/O ports static initializer.
|
||||||
|
@ -159,7 +160,7 @@ typedef struct {
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
iomode_t default_mode;
|
iomode_t default_mode;
|
||||||
const spc560p_pcr_init_t *pcrs;
|
const spc560p_siul_init_t *inits;
|
||||||
const uint8_t *padsels;
|
const uint8_t *padsels;
|
||||||
} PALConfig;
|
} PALConfig;
|
||||||
|
|
||||||
|
@ -170,28 +171,69 @@ typedef struct {
|
||||||
/**
|
/**
|
||||||
* @brief I/O port 1 identifier.
|
* @brief I/O port 1 identifier.
|
||||||
*/
|
*/
|
||||||
#define IOPORT1 0
|
#define PA 0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief I/O port 2 identifier.
|
* @brief I/O port 2 identifier.
|
||||||
*/
|
*/
|
||||||
#define IOPORT2 1
|
#define PB 1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief I/O port 3 identifier.
|
* @brief I/O port 3 identifier.
|
||||||
*/
|
*/
|
||||||
#define IOPORT3 2
|
#define PC 2
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief I/O port 4 identifier.
|
* @brief I/O port 4 identifier.
|
||||||
*/
|
*/
|
||||||
#define IOPORT4 3
|
#define PD 3
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Implementation, some of the following macros could be implemented as */
|
/* Implementation, some of the following macros could be implemented as */
|
||||||
/* functions, if so please put them in pal_lld.c. */
|
/* functions, if so please put them in pal_lld.c. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Port bit helper macro.
|
||||||
|
* @note Overrides the one in @p pal.h.
|
||||||
|
*
|
||||||
|
* @param[in] n bit position within the port
|
||||||
|
*
|
||||||
|
* @return The bit mask.
|
||||||
|
*/
|
||||||
|
#define PAL_PORT_BIT(n) ((ioportmask_t)(0x8000U >> (n)))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Workaround read port because bad header implementation.
|
||||||
|
*
|
||||||
|
* @param[in] port port identifier
|
||||||
|
* @return The port bits.
|
||||||
|
*
|
||||||
|
* @notapi
|
||||||
|
*/
|
||||||
|
#define PAL_SIUL_READ_PORT(port) (((volatile uint16_t *)SIU.PGPDI)[port])
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Workaround read latch because bad header implementation.
|
||||||
|
*
|
||||||
|
* @param[in] port port identifier
|
||||||
|
* @return The port bits.
|
||||||
|
*
|
||||||
|
* @notapi
|
||||||
|
*/
|
||||||
|
#define PAL_SIUL_READ_LATCH(port) (((volatile uint16_t *)SIU.PGPDO)[port])
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Workaround write port because bad header implementation.
|
||||||
|
*
|
||||||
|
* @param[in] port port identifier
|
||||||
|
* @param[in] bits bits to be written on the specified port
|
||||||
|
*
|
||||||
|
* @notapi
|
||||||
|
*/
|
||||||
|
#define PAL_SIUL_WRITE_PORT(port, bits) \
|
||||||
|
(((volatile uint16_t *)SIU.PGPDO)[port] = (bits))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Low level PAL subsystem initialization.
|
* @brief Low level PAL subsystem initialization.
|
||||||
*
|
*
|
||||||
|
@ -209,7 +251,7 @@ typedef struct {
|
||||||
*
|
*
|
||||||
* @notapi
|
* @notapi
|
||||||
*/
|
*/
|
||||||
#define pal_lld_readport(port) (SIU.PGPDI[port].R)
|
#define pal_lld_readport(port) PAL_SIUL_READ_PORT(port)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Reads the output latch.
|
* @brief Reads the output latch.
|
||||||
|
@ -221,7 +263,7 @@ typedef struct {
|
||||||
*
|
*
|
||||||
* @notapi
|
* @notapi
|
||||||
*/
|
*/
|
||||||
#define pal_lld_readlatch(port) (SIU.PGPDO[port].R)
|
#define pal_lld_readlatch(port) PAL_SIUL_READ_LATCH(port)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Writes a bits mask on a I/O port.
|
* @brief Writes a bits mask on a I/O port.
|
||||||
|
@ -231,7 +273,7 @@ typedef struct {
|
||||||
*
|
*
|
||||||
* @notapi
|
* @notapi
|
||||||
*/
|
*/
|
||||||
#define pal_lld_writeport(port, bits) (SIU.PGPDO[port].R = (bits))
|
#define pal_lld_writeport(port, bits) PAL_SIUL_WRITE_PORT(port, bits)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Pads group mode setup.
|
* @brief Pads group mode setup.
|
||||||
|
@ -264,7 +306,7 @@ typedef struct {
|
||||||
* @notapi
|
* @notapi
|
||||||
*/
|
*/
|
||||||
#define pal_lld_readpad(port, pad) \
|
#define pal_lld_readpad(port, pad) \
|
||||||
(SIU.GPDI.R[((port) * 32) + (15 - (pad))])
|
(SIU.GPDI[((port) * 16) + (pad)].R)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Writes a logical state on an output pad.
|
* @brief Writes a logical state on an output pad.
|
||||||
|
@ -282,7 +324,29 @@ typedef struct {
|
||||||
* @notapi
|
* @notapi
|
||||||
*/
|
*/
|
||||||
#define pal_lld_writepad(port, pad, bit) \
|
#define pal_lld_writepad(port, pad, bit) \
|
||||||
(SIU.GPDO.R[((port) * 32) + (15 - (pad))] = (bit))
|
(SIU.GPDO[((port) * 16) + (pad)].R = (bit))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets a pad logical state to @p PAL_HIGH.
|
||||||
|
*
|
||||||
|
* @param[in] port port identifier
|
||||||
|
* @param[in] pad pad number within the port
|
||||||
|
*
|
||||||
|
* @notapi
|
||||||
|
*/
|
||||||
|
#define pal_lld_setpad(port, pad) \
|
||||||
|
(SIU.GPDO[((port) * 16) + (pad)].R = 1)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Clears a pad logical state to @p PAL_LOW.
|
||||||
|
*
|
||||||
|
* @param[in] port port identifier
|
||||||
|
* @param[in] pad pad number within the port
|
||||||
|
*
|
||||||
|
* @notapi
|
||||||
|
*/
|
||||||
|
#define pal_lld_clearpad(port, pad) \
|
||||||
|
(SIU.GPDO[((port) * 16) + (pad)].R = 0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Pad mode setup.
|
* @brief Pad mode setup.
|
||||||
|
|
Loading…
Reference in New Issue