#include <HCI.hh>
|
| HCI (Board::DigitalPin cs, Board::ExternalInterruptPin irq, SPI::Clock rate=SPI::DEFAULT_CLOCK) |
|
int | read (uint16_t &op, void *args, uint8_t len) |
|
int | write (uint8_t type, uint16_t op, const void *args, uint8_t len) |
|
int | write_P (uint8_t type, uint16_t op, const void *args, uint8_t len) |
|
int | write (uint8_t type, uint16_t op, const void *args, uint8_t len, bool progmem) |
|
int | issue (uint16_t op, const void *args=NULL, uint8_t len=0) |
|
int | issue_P (uint16_t op, const void *args, uint8_t len) |
|
int | await (uint16_t op, void *args=NULL, uint8_t len=0) |
|
int | write_data (uint8_t op, const void *args, uint8_t args_len, const void *data, uint16_t data_len) |
|
int | write_data_P (uint8_t op, const void *args, uint8_t args_len, const void *data, uint16_t data_len) |
|
int | write_data (uint8_t op, const void *args, uint8_t args_len, const void *data, uint16_t data_len, bool progmem) |
|
int | read_data (uint8_t op, void *args, uint8_t args_len, void *data, uint16_t data_len) |
|
void | enable () |
|
void | disable () |
|
bool | is_available () |
|
void | event_handler (Event::Handler *handler) |
|
void | set_clock (Clock rate) |
|
void | set_clock (uint32_t freq) |
|
Host Control Interface (HCI) Protocol for SPI. Abstraction of the communication with CC3000 WiFi module. Handles command issue, data write, and reply and data read. Writes and reads HCI blocks in SPI frame. SPI frames are in big-endian, HCI frames in little-endian, except som data which are in network order (big-endian).
References
- CC3000 Protocol, http://processors.wiki.ti.com/index.php/CC3000_Protocol
Definition at line 38 of file HCI.hh.
SPI Header Operation Code.
Enumerator |
---|
SPI_OP_WRITE |
SPI Write(Payload Length,0).
|
SPI_OP_REPLY |
SPI Reply(device ready).
|
SPI_OP_READ |
SPI Read(0,Payload Length).
|
Definition at line 305 of file HCI.hh.
HCI Message Types.
Enumerator |
---|
HCI_TYPE_CMND |
HCI Command (SPI_OP_WRITE only).
|
HCI_TYPE_DATA |
HCI Data (both SPI_OP_WRITE/READ).
|
HCI_TYPE_PATCH |
HCI Patch (SPI_OP_WRITE only).
|
HCI_TYPE_EVNT |
HCI Event (SPI_OP_READ only).
|
Definition at line 333 of file HCI.hh.
Construct SPI based HCI driver with given chip select and interrupt request pin. May also configure with SPI clock rate.
- Parameters
-
[in] | cs | chip select pin. |
[in] | irq | interrupt request pin. |
[in] | rate | of communication with device. |
Definition at line 69 of file HCI.hh.
int HCI::await |
( |
uint16_t |
op, |
|
|
void * |
args = NULL , |
|
|
uint8_t |
len = 0 |
|
) |
| |
Await HCI event and arguments. Returns argument length or negative error code. The given argument block must be able to hold incoming event message. A default event block is used when passer NULL.
- Parameters
-
[in] | op | HCI event code required. |
[in] | args | pointer to argument block. |
[in] | len | max number of bytes in argument block. |
- Returns
- argument length or negative error code.
Definition at line 123 of file HCI.cpp.
static Clock SPI::Driver::clock |
( |
uint32_t |
freq | ) |
|
|
inlinestaticinherited |
Calculate SPI clock rate (scale factor) for given frequency.
- Parameters
-
[in] | freq | device max frequency (in Hz). |
- Returns
- clock rate.
Definition at line 117 of file SPI.hh.
static Clock SPI::Driver::cycle |
( |
uint16_t |
ns | ) |
|
|
inlinestaticinherited |
Calculate SPI clock rate (scale factor) for given clock cycle time in nano seconds.
- Parameters
-
[in] | ns | min device clock cycle time. |
- Returns
- clock rate.
Definition at line 135 of file SPI.hh.
Disable incoming HCI packets (DATA/EVNT).
Definition at line 243 of file HCI.hh.
Enable incoming HCI packets (DATA/EVNT).
Definition at line 235 of file HCI.hh.
Set event service handler. Called by service() for incoming events.
- Parameters
-
Definition at line 262 of file HCI.hh.
bool HCI::is_available |
( |
| ) |
|
|
inline |
Return true(1) if a packet is available otherwise false(0).
- Returns
- bool.
Definition at line 252 of file HCI.hh.
int HCI::issue |
( |
uint16_t |
op, |
|
|
const void * |
args = NULL , |
|
|
uint8_t |
len = 0 |
|
) |
| |
|
inline |
Issue given HCI command message and arguments. Returns argument length or negative error code.
- Parameters
-
[in] | op | HCI operation command. |
[in] | args | pointer to argument block. |
[in] | len | number of bytes in argument block. |
- Returns
- argument length or negative error code.
Definition at line 140 of file HCI.hh.
int HCI::issue_P |
( |
uint16_t |
op, |
|
|
const void * |
args, |
|
|
uint8_t |
len |
|
) |
| |
|
inline |
Issue given HCI command message and arguments in program memory block. Returns argument length or negative error code.
- Parameters
-
[in] | op | HCI operation command. |
[in] | args | pointer to argument block. |
[in] | len | number of bytes in argument block. |
- Returns
- argument length or negative error code.
Definition at line 153 of file HCI.hh.
int HCI::read |
( |
uint16_t & |
op, |
|
|
void * |
args, |
|
|
uint8_t |
len |
|
) |
| |
Read HCI operation and arguments. Returns argument length or negative error code. The given argument block must be able to hold incoming packet.
- Parameters
-
[out] | op | HCI operation command. |
[in] | args | pointer to argument block. |
[in] | len | max number of bytes in argument block. |
- Returns
- argument length or negative error code.
Definition at line 25 of file HCI.cpp.
int HCI::read_data |
( |
uint8_t |
op, |
|
|
void * |
args, |
|
|
uint8_t |
args_len, |
|
|
void * |
data, |
|
|
uint16_t |
data_len |
|
) |
| |
Issue HCI read data command message and arguments. Returns payload length or negative error code.
- Parameters
-
[in] | op | HCI data operation command. |
[in] | args | pointer to command argument block. |
[in] | args_len | number of bytes in command argument block. |
[in] | data | pointer to data block. |
[in] | data_len | number of bytes in data block. |
- Returns
- argument length or negative error code.
Definition at line 158 of file HCI.cpp.
void SPI::Driver::set_clock |
( |
Clock |
rate | ) |
|
|
inherited |
Set SPI master clock rate.
- Parameters
-
Definition at line 297 of file SPI.cpp.
void SPI::Driver::set_clock |
( |
uint32_t |
freq | ) |
|
|
inlineinherited |
Set SPI master clock frequency.
- Parameters
-
[in] | freq | device max frequency (in Hz). |
Definition at line 157 of file SPI.hh.
int HCI::write |
( |
uint8_t |
type, |
|
|
uint16_t |
op, |
|
|
const void * |
args, |
|
|
uint8_t |
len |
|
) |
| |
|
inline |
Write given HCI type operation and arguments. Returns argument length or negative error code.
- Parameters
-
[in] | type | HCI message type. |
[in] | op | HCI operation command. |
[in] | args | pointer to argument block. |
[in] | len | number of bytes in argument block. |
- Returns
- argument length or negative error code.
Definition at line 100 of file HCI.hh.
int HCI::write |
( |
uint8_t |
type, |
|
|
uint16_t |
op, |
|
|
const void * |
args, |
|
|
uint8_t |
len, |
|
|
bool |
progmem |
|
) |
| |
Write given HCI type operation and arguments. Returns argument length or negative error code.
- Parameters
-
[in] | type | HCI message type. |
[in] | op | HCI operation command. |
[in] | args | pointer to argument block (program memory). |
[in] | len | number of bytes in argument block. |
[in] | progmem | argment block in program memory. |
- Returns
- argument length or negative error code.
Definition at line 81 of file HCI.cpp.
int HCI::write_data |
( |
uint8_t |
op, |
|
|
const void * |
args, |
|
|
uint8_t |
args_len, |
|
|
const void * |
data, |
|
|
uint16_t |
data_len |
|
) |
| |
|
inline |
Write data with given data operation code, argument block and data payload. Returns number of bytes written or negative error code.
- Parameters
-
[in] | op | data operation code. |
[in] | args | pointer to argument block. |
[in] | args_len | number of bytes in argument block. |
[in] | data | pointer to data block |
[in] | data_len | number of bytes in data block. |
- Returns
- number of bytes written or negative error code.
Definition at line 181 of file HCI.hh.
int HCI::write_data |
( |
uint8_t |
op, |
|
|
const void * |
args, |
|
|
uint8_t |
args_len, |
|
|
const void * |
data, |
|
|
uint16_t |
data_len, |
|
|
bool |
progmem |
|
) |
| |
Write data with given data operation code, argument block and data payload in given memory source. Returns number of bytes written or negative error code.
- Parameters
-
[in] | op | data operation code. |
[in] | args | pointer to argument block. |
[in] | args_len | number of bytes in argument block. |
[in] | data | pointer to data block. |
[in] | data_len | number of bytes in data block. |
[in] | progmem | flag data block in program memory. |
- Returns
- number of bytes written or negative error code.
Definition at line 221 of file HCI.cpp.
int HCI::write_data_P |
( |
uint8_t |
op, |
|
|
const void * |
args, |
|
|
uint8_t |
args_len, |
|
|
const void * |
data, |
|
|
uint16_t |
data_len |
|
) |
| |
|
inline |
Write data with given data operation code, argument block and data payload in program memory. Returns number of bytes written or negative error code.
- Parameters
-
[in] | op | data operation code. |
[in] | args | pointer to argument block. |
[in] | args_len | number of bytes in argument block. |
[in] | data | pointer to data block in program memory. |
[in] | data_len | number of bytes in data block. |
- Returns
- number of bytes written or negative error code.
Definition at line 198 of file HCI.hh.
int HCI::write_P |
( |
uint8_t |
type, |
|
|
uint16_t |
op, |
|
|
const void * |
args, |
|
|
uint8_t |
len |
|
) |
| |
|
inline |
Write given HCI type operation and arguments in program memory. Returns argument length or negative error code.
- Parameters
-
[in] | type | HCI message type. |
[in] | op | HCI operation command. |
[in] | args | pointer to argument block in program memory. |
[in] | len | number of bytes in argument block. |
- Returns
- argument length or negative error code.
Definition at line 114 of file HCI.hh.
const uint16_t HCI::DEFAULT_TIMEOUT = 3000 |
|
static |
Default timeout on command/data reply (in ms).
Definition at line 60 of file HCI.hh.
const uint8_t HCI::EVNT_MAX = 64 |
|
staticprotected |
Size of default event block.
Definition at line 353 of file HCI.hh.
volatile bool HCI::m_available |
|
protected |
Request flag.
Definition at line 344 of file HCI.hh.
Device chip select pin.
Definition at line 166 of file SPI.hh.
Event handler for unsolicited events.
Definition at line 350 of file HCI.hh.
Default event block.
Definition at line 356 of file HCI.hh.
List of drivers.
Definition at line 164 of file SPI.hh.
Pulse SPI::Driver::m_pulse |
|
protectedinherited |
Chip select pulse width.
Definition at line 167 of file SPI.hh.
uint8_t SPI::Driver::m_spcr |
|
protectedinherited |
SPI/SPCR hardware control register setting.
Definition at line 173 of file SPI.hh.
uint8_t SPI::Driver::m_spsr |
|
protectedinherited |
SPI/SPSR hardware status register.
Definition at line 174 of file SPI.hh.
Reply timeout in milli-seconds.
Definition at line 347 of file HCI.hh.
The documentation for this class was generated from the following files: