Ningkai Wu / Mbed 2 deprecated test_spi_ble

Dependencies:   mbed-rtos mbed

Committer:
wninghj
Date:
Thu Apr 05 21:26:10 2018 +0000
Revision:
0:39b7f3158ebe
TEAM12 DJ;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wninghj 0:39b7f3158ebe 1 /******************************************************************************/
wninghj 0:39b7f3158ebe 2 /*!
wninghj 0:39b7f3158ebe 3 @file sdep.h
wninghj 0:39b7f3158ebe 4 @author hathach
wninghj 0:39b7f3158ebe 5
wninghj 0:39b7f3158ebe 6 @section LICENSE
wninghj 0:39b7f3158ebe 7
wninghj 0:39b7f3158ebe 8 Software License Agreement (BSD License)
wninghj 0:39b7f3158ebe 9
wninghj 0:39b7f3158ebe 10 Copyright (c) 2013, K. Townsend (microBuilder.eu)
wninghj 0:39b7f3158ebe 11 Copyright (c) 2014, Adafruit Industries (adafruit.com)
wninghj 0:39b7f3158ebe 12
wninghj 0:39b7f3158ebe 13 All rights reserved.
wninghj 0:39b7f3158ebe 14
wninghj 0:39b7f3158ebe 15 Redistribution and use in source and binary forms, with or without
wninghj 0:39b7f3158ebe 16 modification, are permitted provided that the following conditions are met:
wninghj 0:39b7f3158ebe 17 1. Redistributions of source code must retain the above copyright
wninghj 0:39b7f3158ebe 18 notice, this list of conditions and the following disclaimer.
wninghj 0:39b7f3158ebe 19 2. Redistributions in binary form must reproduce the above copyright
wninghj 0:39b7f3158ebe 20 notice, this list of conditions and the following disclaimer in the
wninghj 0:39b7f3158ebe 21 documentation and/or other materials provided with the distribution.
wninghj 0:39b7f3158ebe 22 3. Neither the name of the copyright holders nor the
wninghj 0:39b7f3158ebe 23 names of its contributors may be used to endorse or promote products
wninghj 0:39b7f3158ebe 24 derived from this software without specific prior written permission.
wninghj 0:39b7f3158ebe 25
wninghj 0:39b7f3158ebe 26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
wninghj 0:39b7f3158ebe 27 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
wninghj 0:39b7f3158ebe 28 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
wninghj 0:39b7f3158ebe 29 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
wninghj 0:39b7f3158ebe 30 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
wninghj 0:39b7f3158ebe 31 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
wninghj 0:39b7f3158ebe 32 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
wninghj 0:39b7f3158ebe 33 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
wninghj 0:39b7f3158ebe 34 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
wninghj 0:39b7f3158ebe 35 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
wninghj 0:39b7f3158ebe 36 */
wninghj 0:39b7f3158ebe 37 /******************************************************************************/
wninghj 0:39b7f3158ebe 38 #ifndef _SDEP_H_
wninghj 0:39b7f3158ebe 39 #define _SDEP_H_
wninghj 0:39b7f3158ebe 40
wninghj 0:39b7f3158ebe 41 #include "common_header.h"
wninghj 0:39b7f3158ebe 42
wninghj 0:39b7f3158ebe 43 #define SDEP_MAX_PACKETSIZE 16 // Maximum payload per packet
wninghj 0:39b7f3158ebe 44
wninghj 0:39b7f3158ebe 45 /******************************************************************************/
wninghj 0:39b7f3158ebe 46 /*!
wninghj 0:39b7f3158ebe 47 This enumeration is used to make sure that each command has a unique
wninghj 0:39b7f3158ebe 48 ID, and is used to create the command lookup table enum further down
wninghj 0:39b7f3158ebe 49 */
wninghj 0:39b7f3158ebe 50 /******************************************************************************/
wninghj 0:39b7f3158ebe 51 typedef enum
wninghj 0:39b7f3158ebe 52 {
wninghj 0:39b7f3158ebe 53 SDEP_CMDTYPE_INITIALIZE = 0xBEEF, /**< Controls the on board LED(s) */
wninghj 0:39b7f3158ebe 54 SDEP_CMDTYPE_AT_WRAPPER = 0x0A00,
wninghj 0:39b7f3158ebe 55 SDEP_CMDTYPE_BLE_UARTTX = 0x0A01,
wninghj 0:39b7f3158ebe 56 SDEP_CMDTYPE_BLE_UARTRX = 0x0A02,
wninghj 0:39b7f3158ebe 57 } sdepCmdType_t;
wninghj 0:39b7f3158ebe 58
wninghj 0:39b7f3158ebe 59 /******************************************************************************/
wninghj 0:39b7f3158ebe 60 /*!
wninghj 0:39b7f3158ebe 61 The first byte of every transfer defines the message type
wninghj 0:39b7f3158ebe 62 */
wninghj 0:39b7f3158ebe 63 /******************************************************************************/
wninghj 0:39b7f3158ebe 64 typedef enum
wninghj 0:39b7f3158ebe 65 {
wninghj 0:39b7f3158ebe 66 SDEP_MSGTYPE_COMMAND = 0x10,
wninghj 0:39b7f3158ebe 67 SDEP_MSGTYPE_RESPONSE = 0x20,
wninghj 0:39b7f3158ebe 68 SDEP_MSGTYPE_ALERT = 0x40,
wninghj 0:39b7f3158ebe 69 SDEP_MSGTYPE_ERROR = 0x80
wninghj 0:39b7f3158ebe 70 } sdepMsgType_t;
wninghj 0:39b7f3158ebe 71
wninghj 0:39b7f3158ebe 72 /******************************************************************************/
wninghj 0:39b7f3158ebe 73 /*!
wninghj 0:39b7f3158ebe 74 4-byte header for SDEP messages
wninghj 0:39b7f3158ebe 75 */
wninghj 0:39b7f3158ebe 76 /******************************************************************************/
wninghj 0:39b7f3158ebe 77 typedef struct ATTR_PACKED {
wninghj 0:39b7f3158ebe 78 uint8_t msg_type; // 8-bit message type indicator (sdepMsgType_t)
wninghj 0:39b7f3158ebe 79
wninghj 0:39b7f3158ebe 80 union
wninghj 0:39b7f3158ebe 81 {
wninghj 0:39b7f3158ebe 82 uint16_t cmd_id; // 16-bit command ID
wninghj 0:39b7f3158ebe 83 struct
wninghj 0:39b7f3158ebe 84 {
wninghj 0:39b7f3158ebe 85 uint8_t cmd_id_low;
wninghj 0:39b7f3158ebe 86 uint8_t cmd_id_high;
wninghj 0:39b7f3158ebe 87 };
wninghj 0:39b7f3158ebe 88 };
wninghj 0:39b7f3158ebe 89
wninghj 0:39b7f3158ebe 90 struct ATTR_PACKED
wninghj 0:39b7f3158ebe 91 {
wninghj 0:39b7f3158ebe 92 uint8_t length : 7; // Payload length (for this packet)
wninghj 0:39b7f3158ebe 93 uint8_t more_data : 1; // 'more' bit for multiple packet transfers
wninghj 0:39b7f3158ebe 94 };
wninghj 0:39b7f3158ebe 95 } sdepMsgHeader_t;
wninghj 0:39b7f3158ebe 96
wninghj 0:39b7f3158ebe 97 /******************************************************************************/
wninghj 0:39b7f3158ebe 98 /*!
wninghj 0:39b7f3158ebe 99 SDEP command message
wninghj 0:39b7f3158ebe 100 */
wninghj 0:39b7f3158ebe 101 /******************************************************************************/
wninghj 0:39b7f3158ebe 102 typedef struct ATTR_PACKED
wninghj 0:39b7f3158ebe 103 {
wninghj 0:39b7f3158ebe 104 sdepMsgHeader_t header;
wninghj 0:39b7f3158ebe 105 uint8_t payload[SDEP_MAX_PACKETSIZE];
wninghj 0:39b7f3158ebe 106 } sdepMsgCommand_t;
wninghj 0:39b7f3158ebe 107
wninghj 0:39b7f3158ebe 108 /******************************************************************************/
wninghj 0:39b7f3158ebe 109 /*!
wninghj 0:39b7f3158ebe 110 Response message struct (same as sdepMsgCommand_t)
wninghj 0:39b7f3158ebe 111 */
wninghj 0:39b7f3158ebe 112 /******************************************************************************/
wninghj 0:39b7f3158ebe 113 typedef sdepMsgCommand_t sdepMsgResponse_t;
wninghj 0:39b7f3158ebe 114
wninghj 0:39b7f3158ebe 115 /******************************************************************************/
wninghj 0:39b7f3158ebe 116 /*!
wninghj 0:39b7f3158ebe 117 Alert message struct
wninghj 0:39b7f3158ebe 118 */
wninghj 0:39b7f3158ebe 119 /******************************************************************************/
wninghj 0:39b7f3158ebe 120 typedef sdepMsgCommand_t sdepMsgAlert_t;
wninghj 0:39b7f3158ebe 121
wninghj 0:39b7f3158ebe 122 #endif