AVR: Add PAL line support in XMEGA lld.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10591 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
Theodore Ateba 2017-09-16 15:50:30 +00:00
parent 18d0b140b8
commit 6c0086f449
2 changed files with 187 additions and 2 deletions

View File

@ -151,6 +151,88 @@ void _pal_lld_setgroupmode(ioportid_t port,
} }
} }
/**
* @brief Pad event enable.
* @details This function programs an event callback in the specified mode.
* @note Programming an unknown or unsupported mode is silently ignored.
*
* @param[in] port port identifier
* @param[in] pad pad number within the port
* @param[in] mode pad event mode
* @param[in] callback event callback function
* @param[in] arg callback argument
*
* @notapi
*/
void _pal_lld_enablepadevent(ioportid_t port,
iopadid_t pad,
ioeventmode_t mode,
palcallback_t callback,
void *arg) {
(void)port;
(void)pad;
(void)mode;
(void)callback;
(void)arg;
/* TODO: Implement the interruption here. */
/*
#if (port == IOPORT4)
#elif (port == IOPORT5)
#else
#error The selected port dont have an EXT INTx pin.
*/
//}
}
/**
* @brief Make a line identifier with a given port and pad identifiers.
*
* @param[in] port the port identifier
* @param[in] pad the pad identifier
*
* @return line the builded line
*
* @notapi
*/
ioline_t _pal_lld_setlineid(ioportid_t port, uint8_t pad) {
ioline_t line;
line.port = port;
line.pad = pad;
return line;
}
/**
* @brief Get a port identifier from a line identifier.
*
* @param[in] line the line identifier
*
* @return port the port of the corresponding line
*
* @notapi
*/
ioportid_t _pal_lld_getportfromline(ioline_t line) {
return line.port;
}
/**
* @brief Get a pad identifier from a line identifier.
*
* @param[in] line the line identifier
*
* @return pad the pad of the corresponding line
*
* @notapi
*/
uint8_t _pal_lld_getpadfromline(ioline_t line) {
return line.pad;
}
#endif /* HAL_USE_PAL */ #endif /* HAL_USE_PAL */
/** @} */ /** @} */

View File

@ -49,6 +49,35 @@
*/ */
#define PAL_WHOLE_PORT ((ioportmask_t)0xFF) #define PAL_WHOLE_PORT ((ioportmask_t)0xFF)
/**
* @name Line handling macros
* @{
*/
/**
* @brief Forms a line identifier.
* @details A port/pad pair are encoded into an @p ioline_t type. The encoding
* of this type is platform-dependent.
* @note In this driver the pad number and the port identifier are
* encoded in a structure of type ioline_t.
*/
#define PAL_LINE(port, pad) _pal_lld_setlineid(port, pad)
/**
* @brief Decodes a port identifier from a line identifier.
*/
#define PAL_PORT(line) _pal_lld_getportfromline(line)
/**
* @brief Decodes a pad identifier from a line identifier.
*/
#define PAL_PAD(line) _pal_lld_getpadfromline(line)
/**
* @brief Value identifying an invalid line.
*/
#define PAL_NOLINE 0U
/** @} */
/** /**
* @brief AVR setup registers. * @brief AVR setup registers.
*/ */
@ -122,15 +151,32 @@ typedef uint8_t ioportmask_t;
*/ */
typedef uint8_t iomode_t; typedef uint8_t iomode_t;
/** /**
* @brief Port Identifier. * @brief Port Identifier.
* @details This type can be a scalar or some kind of pointer, do not make * @details This type can be a scalar or some kind of pointer, do not make
* any assumption about it, use the provided macros when populating * any assumption about it, use the provided macros when populating
* variables of this type. * variables of this type.
*/ */
//typedef volatile avr_gpio_registers_t * ioportid_t;
typedef volatile PORT_t * ioportid_t; typedef volatile PORT_t * ioportid_t;
/**
* @brief Type of an pad identifier.
*/
typedef uint8_t iopadid_t;
/**
* @brief Type of an I/O line.
*/
typedef struct {
ioportid_t port; /* Line port identifier. */
iopadid_t pad; /* Line pad identifier. */
}ioline_t;
/**
* @brief Type of an event mode.
*/
typedef uint8_t ioeventmode_t;
/*===========================================================================*/ /*===========================================================================*/
/* I/O Ports Identifiers. */ /* I/O Ports Identifiers. */
/*===========================================================================*/ /*===========================================================================*/
@ -294,6 +340,60 @@ typedef volatile PORT_t * ioportid_t;
*/ */
#define pal_lld_clearpad(port, pad) ((port)->OUTCLR |= (1 << pad)) #define pal_lld_clearpad(port, pad) ((port)->OUTCLR |= (1 << pad))
/**
* @brief Pad event enable.
* @details This function programs an event callback in the specified mode.
* @note Programming an unknown or unsupported mode is silently ignored.
*
* @param[in] port port identifier
* @param[in] pad pad number within the port
* @param[in] mode pad event mode
* @param[in] callback event callback function
* @param[in] arg callback argument
*
* @notapi
*/
#define pal_lld_enablepadevent(port, pad, mode, callback, arg) \
_pal_lld_enablepadevent(port, pad, mode, callback, arg)
/**
* @brief Pad event disable.
* @details This function disables previously programmed event callbacks.
*
* @param[in] port port identifier
* @param[in] pad pad number within the port
*
* @notapi
*/
#define pal_lld_disablepadevent(port, pad) \
_pal_lld_disablepadevent(port, pad)
/**
* @brief Returns a PAL event structure associated to a pad.
*
* @param[in] port port identifier
* @param[in] pad pad number within the port
*
* @notapi
*/
#define pal_lld_get_pad_event(port, pad) \
&_pal_events[pad]; (void)(port)
/**
* @brief Returns a PAL event structure associated to a line.
*
* @param[in] line line identifier
*
* @notapi
*/
#define pal_lld_get_line_event(line) \
&_pal_events[PAL_PAD(line)]
#if !defined(__DOXYGEN__)
extern const PALConfig pal_default_config;
extern palevent_t _pal_events[16];
#endif
extern ROMCONST PALConfig pal_default_config; extern ROMCONST PALConfig pal_default_config;
#ifdef __cplusplus #ifdef __cplusplus
@ -303,6 +403,9 @@ extern "C" {
void _pal_lld_setgroupmode(ioportid_t port, void _pal_lld_setgroupmode(ioportid_t port,
ioportmask_t mask, ioportmask_t mask,
iomode_t mode); iomode_t mode);
ioline_t _pal_lld_setlineid(ioportid_t port, uint8_t pad);
ioportid_t _pal_lld_getportfromline(ioline_t line);
uint8_t _pal_lld_getpadfromline(ioline_t line);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif