engine_control/source/firmware/kernel/driver/cc110x.h

89 lines
2.6 KiB
C
Raw Normal View History

2016-07-23 05:59:54 +00:00
/*
* cc110x.h
*
* Created on: Jul 20, 2012
* Author: tkl
*/
#ifndef CC110X_H_
#define CC110X_H_
enum cc110x_radio_mode {
CC110X_RADIO_MODE_NONE = 0,
CC110X_RADIO_MODE_IDLE,
CC110X_RADIO_MODE_RX,
CC110X_RADIO_MODE_TX,
CC110X_RADIO_MODE_PWD
};
enum cc110x_strobe_cmd {
STROBE_SRES = 0,
STROBE_SFSTXON,
STROBE_SXOFF,
STROBE_SCAL,
STROBE_SRX,
STROBE_STX,
STROBE_SIDLE,
STROBE_SWOR,
STROBE_SPWD,
STROBE_SFRX,
STROBE_SFTX,
STROBE_SWORRST,
STROBE_SNOP
};
enum cc110x_it_type {
IT_TYPE_NONE = 0,
IT_TYPE_RX_COMPLETE,
IT_TYPE_TX_COMPLETE
};
typedef void (*cc110x_fp_init)(const void *);
typedef void (*cc110x_fp_write_pa_table)(const void *);
typedef void (*cc110x_fp_set_radio_mode)(const void *, enum cc110x_radio_mode);
typedef char (*cc110x_fp_strobe)(const void *, enum cc110x_strobe_cmd);
typedef int (*cc110x_fp_write)(const void *, const char *, int);
typedef int (*cc110x_fp_read)(const void *, char *, int);
typedef int (*cc110x_fp_set_it_cb)(const void *, const void *, const void *);
typedef int (*cc110x_fp_get_rx_count)(const void *);
//! \brief Contains the function pointer to access the cc110x driver.
struct cc110x_fp {
/*! Function pointer to the init function. */
const cc110x_fp_init init;
/*! Function pointer to the strobe function. */
const cc110x_fp_strobe strobe;
/*! Function pointer to the write function. */
const cc110x_fp_write write;
/*! Function pointer to the read function. */
const cc110x_fp_read read;
/*! Function pointer to the write_pa_table function. */
const cc110x_fp_write_pa_table write_pa_table;
/*! Function pointer to the set_it_callback function. */
const cc110x_fp_set_it_cb set_it_callback;
/*! Function pointer to the get_rx_count function. */
const cc110x_fp_get_rx_count get_rx_count;
};
//! \brief The cc110x driver object.
struct cc110x {
/*! Radio mode. */
enum cc110x_radio_mode *radio_mode;
/*! Architecture depended underlaying device (i.e. spi_t or NULL). */
const void *arch_dep_device;
/*! Function pointer for the cc110x driver access. */
const struct cc110x_fp *fp;
};
int cc110x_open(const struct cc110x *cc110x);
int cc110x_close(const struct cc110x *cc110x);
int cc110x_write(const struct cc110x *cc110x, const char *buffer, int size);
int cc110x_read(const struct cc110x *cc110x, char *buffer, int size);
int cc110x_get_rx_count(const struct cc110x *cc110x);
void cc110x_set_radio_mode(const struct cc110x *cc110x, enum cc110x_radio_mode mode);
enum cc110x_radio_mode cc110x_get_radio_mode(const struct cc110x *cc110x);
void cc110x_write_pa_table(const struct cc110x *cc110x);
void cc110x_strobe(const struct cc110x *cc110x, enum cc110x_strobe_cmd cmd);
#endif /* CC110X_H_ */