X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fdrv%2Fsipo.h;h=10918cd7de14cc3ec52ea2fe4562791a2df4d595;hb=e380431860a0d4e90b0b06aa628099637a572101;hp=940f85377c7dba38e142cdff59d174191a5252bb;hpb=96a9c1585a17bce4abf3b393e1c307388878adbb;p=bertos.git diff --git a/bertos/drv/sipo.h b/bertos/drv/sipo.h index 940f8537..10918cd7 100644 --- a/bertos/drv/sipo.h +++ b/bertos/drv/sipo.h @@ -33,7 +33,6 @@ * \brief Generic Serial-in, Parallel-out implementation (SIPO). * * - * \version $Id$ * * \author Andrea Grandi * \author Daniele Basile @@ -43,20 +42,46 @@ * $WIZ$ module_hw = "bertos/hw/hw_sipo.h" */ +#ifndef DRV_SIPO_H +#define DRV_SIPO_H +#include "hw/hw_sipo.h" +#include "cfg/cfg_sipo.h" +#include -#ifndef DRV_SIPO_H -#define DRV_SIPO_H +/* + * The following macros are needed to maintain compatibility with older sipo API. + * They can be safely removed once the old API is removed. + */ -#include "hw/hw_sipo.h" + /** + * \addtogroup sipo_api + * \{ + */ +#if COMPILER_C99 + #define sipo_init(...) PP_CAT(sipo_init ## _, COUNT_PARMS(__VA_ARGS__)) (__VA_ARGS__) +#else + /** + * Initialize SIPO module. + * + * To initialize the module you can write this code: + * \code + * Sipo ctx; + * sipo_init(&ctx, settings); + * \endcode + */ + #define sipo_init(args...) PP_CAT(sipo_init ## _, COUNT_PARMS(args)) (args) + +#endif +/**\}*/ -#include #define SIPO_DATAORDER_START_LSB 1 #define SIPO_DATAORDER_START_MSB 0x80 +#if !CONFIG_SIPO_DISABLE_OLD_API /** * Define enum to set sipo data order. */ @@ -98,6 +123,31 @@ typedef struct Sipo SipoBitOrder bit_order; ///< Set the order of pushed bits in sipo. } Sipo; +#else /* New api */ + +#define SIPO_DATAORDER BV(0) +#define SIPO_DATAORDER_MSB BV(0) ///< MSB sipo data order setting +#define SIPO_DATAORDER_LSB 0 ///< LSB sipo data order setting + +#define SIPO_CLOCK_POL BV(1) +#define SIPO_START_LOW BV(1) ///< sipo clock start level high setting +#define SIPO_START_HIGH 0 ///< sipo clock start level low setting + +#define SIPO_LOAD_LEV BV(2) +#define SIPO_LOW_TO_HIGH BV(2) ///< sipo load high signal level setting. +#define SIPO_HIGH_TO_LOW 0 ///< sipo load low signal level setting. + +/** + * Sipo KFile context structure. + */ +typedef struct Sipo +{ + KFile fd; ///< File descriptor. + SipoMap device; ///< Descriptor of the device that we want drive. + uint8_t settings; +} Sipo; + +#endif /** * ID for sipo. @@ -113,7 +163,8 @@ INLINE Sipo * SIPO_CAST(KFile *fd) return (Sipo *)fd; } -void sipo_init(Sipo *fd); +void sipo_init_1(Sipo *fd); +void sipo_init_3(Sipo *fd, SipoMap dev, uint8_t settings); -#endif // DRV_SIPO_H +#endif /* DRV_SIPO_H */