version_2.0
Dependents: cc3000_ping_demo_try_2
Fork of cc3000_hostdriver_mbedsocket by
Diff: cc3000_hci.cpp
- Revision:
- 45:50ab13d8f2dc
- Parent:
- 26:456f73ed2a75
--- a/cc3000_hci.cpp Sun Oct 13 11:46:21 2013 +0200 +++ b/cc3000_hci.cpp Wed Nov 06 17:56:25 2013 +0100 @@ -51,8 +51,8 @@ } uint16_t cc3000_hci::command_send(uint16_t op_code, uint8_t *buffer, uint8_t length) { - unsigned char *stream; - + uint8_t *stream; + DBG_HCI_CMD("Command Sent : 0x%04X", op_code); stream = (buffer + SPI_HEADER_SIZE); @@ -67,7 +67,7 @@ uint32_t cc3000_hci::data_send(uint8_t op_code, uint8_t *args, uint16_t arg_length, uint16_t data_length, const uint8_t *tail, uint16_t tail_length) { - unsigned char *stream; + uint8_t *stream; stream = ((args) + SPI_HEADER_SIZE); @@ -83,7 +83,7 @@ } void cc3000_hci::data_command_send(uint16_t op_code, uint8_t *buffer, uint8_t arg_length, uint16_t data_length) { - unsigned char *stream = (buffer + SPI_HEADER_SIZE); + uint8_t *stream = (buffer + SPI_HEADER_SIZE); UINT8_TO_STREAM(stream, HCI_TYPE_DATA); UINT8_TO_STREAM(stream, op_code); @@ -97,21 +97,18 @@ } void cc3000_hci::patch_send(uint8_t op_code, uint8_t *buffer, uint8_t *patch, uint16_t data_length) { - unsigned short usTransLength; - unsigned char *stream = (buffer + SPI_HEADER_SIZE); + uint16_t usTransLength; + uint8_t *stream = (buffer + SPI_HEADER_SIZE); UINT8_TO_STREAM(stream, HCI_TYPE_PATCH); UINT8_TO_STREAM(stream, op_code); stream = UINT16_TO_STREAM(stream, data_length + SIMPLE_LINK_HCI_PATCH_HEADER_SIZE); - if (data_length <= SL_PATCH_PORTION_SIZE) - { + if (data_length <= SL_PATCH_PORTION_SIZE) { UINT16_TO_STREAM(stream, data_length); stream = UINT16_TO_STREAM(stream, data_length); memcpy((buffer + SPI_HEADER_SIZE) + HCI_PATCH_HEADER_SIZE, patch, data_length); // Update the opcode of the event we will be waiting for _spi.write(buffer, data_length + HCI_PATCH_HEADER_SIZE); - } - else - { + } else { usTransLength = (data_length/SL_PATCH_PORTION_SIZE); UINT16_TO_STREAM(stream, data_length + SIMPLE_LINK_HCI_PATCH_HEADER_SIZE + usTransLength*SIMPLE_LINK_HCI_PATCH_HEADER_SIZE); @@ -124,21 +121,16 @@ _spi.write(buffer, SL_PATCH_PORTION_SIZE + HCI_PATCH_HEADER_SIZE); stream = (buffer + SPI_HEADER_SIZE); - while (data_length) - { - if (data_length <= SL_PATCH_PORTION_SIZE) - { + while (data_length) { + if (data_length <= SL_PATCH_PORTION_SIZE) { usTransLength = data_length; data_length = 0; - - } - else - { + } else { usTransLength = SL_PATCH_PORTION_SIZE; data_length -= usTransLength; } - *(unsigned short *)stream = usTransLength; + *(uint16_t *)stream = usTransLength; memcpy(stream + SIMPLE_LINK_HCI_PATCH_HEADER_SIZE, patch, usTransLength); patch += usTransLength; @@ -148,4 +140,4 @@ } } -} +} // mbed_cc3000 namespace