BC-ANT-SERIAL communication library.

Dependents:   bc_ant-sample bc_ant-receiver

BeatcraftさんのBC-ANT-SERIAL を mbedで動かしてみました。

BC-ANT-SERIAL については、以下を参照ください。

http://labs.beatcraft.com/ja/index.php?ANT%2FBC-ANT-SERIAL%20%C0%E2%CC%C0%BD%F1

以下のような構成で、BC-ANT-SERIALを 9600bps に設定し、 BC-ANT-USB相手を相手に通信を行いました。 (下図は受信例ですが、逆方向の送信も確認しました。)

/media/uploads/MRSa/bc-ant_mbed2.jpeg

なお、BC-ANT-SERIALを9600bpsの設定にする場合は、BR2をショートさせます。 /media/uploads/MRSa/bc-ant-serial9600.jpg

本ライブラリは、@ryuchi さんの ANT/LPC1114用ライブラリ をベタに持って来てmbed用にしました。

(UARTを使っている部分をSerialクラスに置き換えた程度で動いちゃいました。。。あんまり中身を見ていません。。)

ライブラリ使用例

受信で使用する場合

受信で使用する場合のmain.cpp例

#include "mbed.h"
#include "bc_ant.h"
 
DigitalOut myled(LED1);               // LEDチカチカ
 
Serial pc(USBTX, USBRX);           // USBへのデータ通信
bc_ant antPort(p13, p14, p15);    // for BC-ANT-SERIALの接続。(9600bps, p13, p14, ctsにp15)

/** ANT用の定数定義 **/
#define MAX_BUFSIZE   64          // 受信バッファサイズ用の定義
#define ANT_CH         0               // チャンネル番号
#define DEVICE_NUMBER 65      // デバイス番号
 
/**
 *  BC-ANT-SERIALでデータを受信した時の処理
 */
void receivedFromAnt()
{
    // 受信データを受け取る領域の確保
    uint8_t receivedLength = 0;
    uint8_t receivedBuffer[MAX_BUFSIZE];

    // データを受信する
    receivedLength = antPort.BC_ANT_RecvPacket(receivedBuffer, MAX_BUFSIZE);
 
   // 受信したデータを printf()して、PCのターミナルに表示する。
    printf("RX(%3d):", receivedLength);
    for (int index = 0; index < receivedLength; index++)
    {
        printf("%02x ", receivedBuffer[index]);
    }
    printf("\r\n");
}

/**
 *   BC-ANT-SERIALの(受信)初期化処理
 */
int initialize_ANTport()
{
    antPort.ANT_ResetSystem();
    antPort.ANT_AssignChannel(ANT_CH, ANT_Bidirectional_Slave, 0);   // チャンネルタイプの設定
    antPort.ANT_SetChannelId(ANT_CH,  DEVICE_NUMBER, 1, 1);          // チャンネルIDの設定
    antPort.ANT_SetChannelPeriod_Hz(ANT_CH, 4);                                // チャンネルピリオドの設定
    antPort.ANT_SetChannelRFFreq(ANT_CH, 4);                                    // 通信周波数の設定: 2404 MHz
    antPort.ANT_OpenChannel(ANT_CH);

    // コールバック関数の設定 (データを受信したら receivedFromAnt() を呼び出してもらうよう設定する)
    antPort.attach(&receivedFromAnt);

    return (0);
}
 
/**
 *    メイン処理
 */
int main()
{
    pc.baud(9600);                    // mbed と PCの間の通信速度を 9600bpsに設定する。
    initialize_ANTport();             // BC-ANT-SERIALを受信用に初期化する。
    printf("--- READY ----\r\n");  // 準備が出来たことを PCのターミナルに通知する。

    // 以下は、LEDチカチカ。 (デフォルトで生成される処理をそのまま残してます)
    while(1) {
        myled = 1;
        wait(0.2);
        myled = 0;
        wait(0.2);
    }
}

送信で使用する場合

送信で使用する場合は、受信と比較して antPort.ANT_AssignChannel() と ANT_OpenChannel()のあとの処理が異なるぐらいです。

送受信で、antPort.ANT_SetChannelId(), antPort.ANT_SetChannelPeriod_Hz(), antPort.ANT_SetChannelRFFreq() の設定は合わせておく必要がありそうです。

送信で使用する場合のmain.cpp例

#include "mbed.h"
#include "bc_ant.h"

DigitalOut myled(LED1);               // LEDチカチカ

Serial pc(USBTX, USBRX);           // USBへのデータ通信
bc_ant antPort(p13, p14, p15);    // for BC-ANT-SERIALの接続。(9600bps, p13, p14, ctsにp15)

/** ANT用の定数定義 **/
#define MAX_BUFSIZE   64          // 受信バッファサイズ用の定義
#define ANT_CH         0               // チャンネル番号
#define DEVICE_NUMBER 65      // デバイス番号


/**
 *    PCのターミナルからキー入力された時の処理
 *    (キー入力の情報をAntポートに送る)
 */
void receivedPc()
{
    uint8_t buffer[MAX_BUFSIZE] =
    {
        0xff, 0xff, 0xff, 0xff, 0xff,
        0xff, 0xff, 0xff, 0xff, 0xff
    };
    while (pc.readable())
    {
        // データを取り出して、それをAntに送る
        unsigned char receivedChar =  (pc.getc() & 0xff);
        buffer[0] = receivedChar;
        antPort.ANT_SendAcknowledgedData(0, buffer);
    }
}

/**
 *   初期化処理
 */
int initialize_ANTport()
{
    antPort.ANT_ResetSystem();
    antPort.ANT_AssignChannel(ANT_CH, ANT_Bidirectional_Slave, 0);   // チャンネルタイプの設定
    antPort.ANT_SetChannelId(ANT_CH,  DEVICE_NUMBER, 1, 1);          // チャンネルIDの設定
    antPort.ANT_SetChannelPeriod_Hz(ANT_CH, 4);                                // チャンネルピリオドの設定
    antPort.ANT_SetChannelRFFreq(ANT_CH, 4);                                    // 通信周波数の設定: 2404 MHz
    antPort.ANT_OpenChannel(ANT_CH);
    {
        uint8_t buffer[MAX_BUFSIZE] =
        {
            0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
        };
        antPort.ANT_SendBroadcastData(0, buffer);  // データ送信?
    }
    return (0);
}

/**
 *   メイン処理
 */
int main()
{
    pc.baud(9600);                                      // PCとの通信速度を 9600bps に設定する
    pc.attach(&receivedPc,Serial::RxIrq);    // PCからデータが送られてきた場合、receviedPc() 関数を呼び出す用に設定する

    initialize_ANTport()   // BC-ANT-SERIALの初期化を行う

    printf("--- READY ----\r\n");  // 準備が出来たことを PCのターミナルに通知する。
    
    // 以下は、LEDチカチカ。 (デフォルトで生成される処理をそのまま残してます)
    while(1) {
        myled = 1;
        wait(0.2);
        myled = 0;
        wait(0.2);
    }
}

参考:BC-ANT-USB側

動作確認をした BC-ANT-USB 側は、ANT/BCA_Lib のページにある BCA_Lib.zipのSendCB.exe, RecvCB.exe を 利用させて頂きました。

ただし、BCA_OpenChannel() の引数は以下のように変更しました。

SendCB.cppで変更した箇所(SendCB.cpp:52行目あたり)

	res = BCA_OpenChannel(dev,						//	device
						  0,						//	channel no
						  BCA_CHANNEL_TYPE_MASTER,	//	channel type
						  BCA_CHANNEL_NOSHARED,		//	shared channel
						  65,						//	device no
						  1,						//	device type
						  1,						//	trans type
						  4,						//	freq
						  4);						//	hz

RecvCB.cppで変更した箇所(RecvCB.cpp:54行目あたり)

	res = BCA_OpenChannel(dev,						//	device
						  0,						//	channel no
						  BCA_CHANNEL_TYPE_SLAVE,	//	channel type
						  BCA_CHANNEL_NOSHARED,     //	shared channel
						  0,						//	device no
						  0,						//	device type
						  0,						//	trans type
						  4,						//	freq
						  4.0);						//	hz

備忘録

  • ほんとにベタ移植で動いた、という段階なので、中身を確認して理解しないといけない。
  • きれいにクラス化したい。
  • ちゃんとコードに説明を書きたい。
Committer:
MRSa
Date:
Sun Mar 17 09:05:20 2013 +0000
Revision:
0:97c748c69103
Child:
1:b166aab45b3f
library for BC-ANT-SERIAL. (initial alfa version)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MRSa 0:97c748c69103 1 /*
MRSa 0:97c748c69103 2 * ant.h
MRSa 0:97c748c69103 3 *
MRSa 0:97c748c69103 4 * Created on: 2012/10/12
MRSa 0:97c748c69103 5 * Author: ryuchi
MRSa 0:97c748c69103 6 *
MRSa 0:97c748c69103 7 * Adopted for mbed by MRSa (17.Mar.2013)
MRSa 0:97c748c69103 8 */
MRSa 0:97c748c69103 9
MRSa 0:97c748c69103 10 #ifndef ANT_H_
MRSa 0:97c748c69103 11 #define ANT_H_
MRSa 0:97c748c69103 12
MRSa 0:97c748c69103 13 #include "mbed.h"
MRSa 0:97c748c69103 14
MRSa 0:97c748c69103 15 #define ANT_SYNCBYTE 0xA4
MRSa 0:97c748c69103 16
MRSa 0:97c748c69103 17 #define ANT_UNASSIGN_CHANNEL 0x41
MRSa 0:97c748c69103 18 #define ANT_ASSIGN_CHANNEL 0x42
MRSa 0:97c748c69103 19 #define ANT_SET_CHANNEL_ID 0x51
MRSa 0:97c748c69103 20 #define ANT_CHANNEL_MESSAGING_PREIOD 0x43
MRSa 0:97c748c69103 21 #define ANT_CHANNEL_SEARCH_TIMEOUT 0x44
MRSa 0:97c748c69103 22 #define ANT_CHANNEL_RF_FREQUENCY 0x45
MRSa 0:97c748c69103 23 #define ANT_SET_NETWORK_KEY 0x46
MRSa 0:97c748c69103 24 #define ANT_TRANSMIT_POWER 0x47
MRSa 0:97c748c69103 25 #define ANT_ADD_CHANNEL_ID 0x59
MRSa 0:97c748c69103 26 #define ANT_CONFIG_LIST_ID 0x5A
MRSa 0:97c748c69103 27 #define ANT_SET_CHANNEL_TX_POWER 0x60
MRSa 0:97c748c69103 28 #define ANT_CHANNEL_LOW_PRIORITY_SERARCH_TIMEOUT 0x63
MRSa 0:97c748c69103 29 #define ANT_SERIAL_NUMBER_CHANNEL_ID 0x65
MRSa 0:97c748c69103 30 #define ANT_ENABLE_EXTENDED_MESSAGGES 0x66
MRSa 0:97c748c69103 31 #define ANT_ENABLE_LED 0x68
MRSa 0:97c748c69103 32 #define ANT_ENABLE_CRYSTAL 0x6D
MRSa 0:97c748c69103 33 #define ANT_FREQUENCY_AGILITY 0x70
MRSa 0:97c748c69103 34 #define ANT_PROXIMITY_SEARCH 0x71
MRSa 0:97c748c69103 35 #define ANT_SET_USB_DESCRIPTOR_STRING 0xC7
MRSa 0:97c748c69103 36 #define ANT_STARTUP_MESSAGE 0x6F
MRSa 0:97c748c69103 37 #define ANT_RESET_SYSTEM 0x4A
MRSa 0:97c748c69103 38 #define ANT_OPEN_CHANNEL 0x4B
MRSa 0:97c748c69103 39 #define ANT_CLOSE_CHANNEL 0x4C
MRSa 0:97c748c69103 40 #define ANT_REQUEST_MESSAGE 0x4D
MRSa 0:97c748c69103 41 #define ANT_OPEN_RX_SCAN_MODE 0x5B
MRSa 0:97c748c69103 42 #define ANT_SLEEP_MESSAGE 0xC5
MRSa 0:97c748c69103 43 #define ANT_BROADCAST_DATA 0x4E
MRSa 0:97c748c69103 44 #define ANT_ACKNOWLEDGED_DATA 0x4F
MRSa 0:97c748c69103 45 #define ANT_BURST_DATA 0x50
MRSa 0:97c748c69103 46 #define ANT_CHANNEL_RESPONSE 0x40
MRSa 0:97c748c69103 47 #define ANT_CHANNEL_EVENT 0x40
MRSa 0:97c748c69103 48 #define ANT_CHANNEL_STATUS 0x52
MRSa 0:97c748c69103 49 #define ANT_CHANNEL_ID 0x51
MRSa 0:97c748c69103 50 #define ANT_VERSION 0x31
MRSa 0:97c748c69103 51 #define ANT_CAPABILITIES 0x54
MRSa 0:97c748c69103 52 #define ANT_DEVICE_SERIAL_NUMBER 0x61
MRSa 0:97c748c69103 53 #define ANT_INIT_CW_TEST_MODE 0x53
MRSa 0:97c748c69103 54 #define ANT_CW_TEST_MODE 0x48
MRSa 0:97c748c69103 55 #define ANT_EXTENDED_BROADCAST_DATA 0x5D
MRSa 0:97c748c69103 56 #define ANT_EXTENDED_ACKNOWLEDGED_DATA 0x5E
MRSa 0:97c748c69103 57 #define ANT_EXTENDED_BURST_DATA 0x5F
MRSa 0:97c748c69103 58
MRSa 0:97c748c69103 59 // Assign Channel: parameters (Channel Type)
MRSa 0:97c748c69103 60 #define ANT_Bidirectional_Slave 0x00
MRSa 0:97c748c69103 61 #define ANT_Bidirectional_Master 0x10
MRSa 0:97c748c69103 62 #define ANT_Shared_Bidirectional_Slave 0x20
MRSa 0:97c748c69103 63 #define ANT_Slave_Receive_Only 0x40
MRSa 0:97c748c69103 64 #define ANT_Master_Transmission_Only 0x50
MRSa 0:97c748c69103 65
MRSa 0:97c748c69103 66 // Assign Channel: parameters (Extened Assignment)
MRSa 0:97c748c69103 67 #define ANT_BACKGRAND_SCANNING_CHANNEL_ENABLE 0x01
MRSa 0:97c748c69103 68 #define ANT_FREQUENCY_AGILITY_ENABLE 0x04
MRSa 0:97c748c69103 69
MRSa 0:97c748c69103 70 // Transmit Power: parameters (Transmission Power)
MRSa 0:97c748c69103 71 #define ANT_TRANSMIT_POWER_MINUS_20DBM 0x00
MRSa 0:97c748c69103 72 #define ANT_TRANSMIT_POWER_MINUS_10DBM 0x01
MRSa 0:97c748c69103 73 #define ANT_TRANSMIT_POWER_MINUS_5DBM 0x02
MRSa 0:97c748c69103 74 #define ANT_TRANSMIT_POWER_0DBM 0x03
MRSa 0:97c748c69103 75
MRSa 0:97c748c69103 76 // Set Channle Tx Power: parameters (Transmission Power)
MRSa 0:97c748c69103 77 #define ANT_SET_CHANNEL_TRANSMIT_POWER_MINUS_20DBM 0x00
MRSa 0:97c748c69103 78 #define ANT_SET_CHANNEL_TRANSMIT_POWER_MINUS_10DBM 0x01
MRSa 0:97c748c69103 79 #define ANT_SET_CHANNEL_TRANSMIT_POWER_MINUS_5DBM 0x02
MRSa 0:97c748c69103 80 #define ANT_SET_CHANNEL_TRANSMIT_POWER_0DBM 0x03
MRSa 0:97c748c69103 81
MRSa 0:97c748c69103 82 // Enable Extended Message: parameters
MRSa 0:97c748c69103 83 #define ANT_EXTENDED_MESSAGE_ENABLE 1
MRSa 0:97c748c69103 84 #define ANT_EXTENDED_MESSAGE_DISABLE 0
MRSa 0:97c748c69103 85
MRSa 0:97c748c69103 86 // Enable LED Message: parameters
MRSa 0:97c748c69103 87 #define ANT_LED_ENABLE 1
MRSa 0:97c748c69103 88 #define ANT_LED_DISABLE 0
MRSa 0:97c748c69103 89
MRSa 0:97c748c69103 90 #define ANT_CRYSTAL_ENABLE 0
MRSa 0:97c748c69103 91
MRSa 0:97c748c69103 92 // Set USB Descriptor:
MRSa 0:97c748c69103 93 #define ANT_USB_DESCRIPTOR_PID_VID 0
MRSa 0:97c748c69103 94 #define ANT_USB_DESCRIPTOR_MANUFACTURE 1
MRSa 0:97c748c69103 95 #define ANT_USB_DESCRIPTOR_DEVICE 2
MRSa 0:97c748c69103 96 #define ANT_USB_DESCRIPTOR_SERIAL_NUMBER 3
MRSa 0:97c748c69103 97
MRSa 0:97c748c69103 98 // Startup Message
MRSa 0:97c748c69103 99 #define ANT_STARTUP_MESSAGE 0x6F
MRSa 0:97c748c69103 100 #define ANT_STARTUP_MESSAGE_POWER_ON_RESET 0x00
MRSa 0:97c748c69103 101 #define ANT_STARTUP_MESSAGE_HARDWARE_RESET_LINE 0x01
MRSa 0:97c748c69103 102 #define ANT_STARTUP_MESSAGE_WATCH_DOG_RESET 0x02
MRSa 0:97c748c69103 103 #define ANT_STARTUP_MESSAGE_COMMAND_RESET 0x20
MRSa 0:97c748c69103 104 #define ANT_STARTUP_MESSAGE_SYNCHRONOUS_RESET 0x40
MRSa 0:97c748c69103 105 #define ANT_STARTUP_MESSAGE_SUSPEND_RESET 0x80
MRSa 0:97c748c69103 106
MRSa 0:97c748c69103 107 #define ANT_DATA_MESSAGE_EXTENDED_FLAG 0x80
MRSa 0:97c748c69103 108
MRSa 0:97c748c69103 109 #define ANT_MESSAGE_RESPONSE_NO_ERROR 0
MRSa 0:97c748c69103 110 #define ANT_MESSAGE_EVENT_RX_SEARCH_TIMEOUT 1
MRSa 0:97c748c69103 111 #define ANT_MESSAGE_EVENT_RX_FAIL 2
MRSa 0:97c748c69103 112 #define ANT_MESSAGE_EVENT_TX 3
MRSa 0:97c748c69103 113 #define ANT_MESSAGE_EVENT_TRANSFER_RX_FAILED 4
MRSa 0:97c748c69103 114 #define ANT_MESSAGE_EVENT_TRANSFER_TX_COMPLETED 5
MRSa 0:97c748c69103 115 #define ANT_MESSAGE_EVENT_TRANSFER_TX_FAILED 6
MRSa 0:97c748c69103 116 #define ANT_MESSAGE_CHANNEL_CLOSED 7
MRSa 0:97c748c69103 117 #define ANT_MESSAGE_EVENT_RX_FAIL_GO_TO_SEARCH 8
MRSa 0:97c748c69103 118 #define ANT_MESSAGE_EVNET_CHANNEL_COLLISION 9
MRSa 0:97c748c69103 119 #define ANT_MESSAGE_EVENT_TRANSFER_TX_START 10
MRSa 0:97c748c69103 120 #define ANT_MESSAGE_CHANNEL_IN_WRONG_STATE 21
MRSa 0:97c748c69103 121 #define ANT_MESSAGE_CHANNEL_NOT_OPEND 22
MRSa 0:97c748c69103 122 #define ANT_MESSAGE_CHANNEL_ID_NOT_SET 24
MRSa 0:97c748c69103 123 #define ANT_MESSAGE_CLOSE_ALL_CHANNELS 25
MRSa 0:97c748c69103 124 #define ANT_MESSAGE_TRANSFER_IN_PROGRESS 31
MRSa 0:97c748c69103 125 #define ANT_MESSAGE_TRANSFER_SEQUENCE_NUMBER_ERROR 32
MRSa 0:97c748c69103 126 #define ANT_MESSAGE_TRANSFER_IN_ERROR 33
MRSa 0:97c748c69103 127 #define ANT_MESSAGE_INVALID_MESSAGE 40
MRSa 0:97c748c69103 128 #define ANT_MESSAGE_INVALID_NETWORK_NUMBER 41
MRSa 0:97c748c69103 129 #define ANT_MESSAGE_LIST_ID 48
MRSa 0:97c748c69103 130 #define ANT_MESSAGE_INVALID_SCAN_TX_CHANNEL 49
MRSa 0:97c748c69103 131 #define ANT_MESSAGE_INVALID_PARAMETER_PROVIDED 51
MRSa 0:97c748c69103 132 #define ANT_MESSAGE_EVENT_QUE_OVERFLOW 53
MRSa 0:97c748c69103 133 #define ANT_MESSAGE_NVM_FULL_ERROR 64
MRSa 0:97c748c69103 134 #define ANT_MESSAGE_WRITE_ERROR 65
MRSa 0:97c748c69103 135
MRSa 0:97c748c69103 136 #define ANT_CHANNEL_STATUS_UN_ASSIGNED 0
MRSa 0:97c748c69103 137 #define ANT_CHANNEL_STATUS_ASSIGNED 1
MRSa 0:97c748c69103 138 #define ANT_CHANNEL_STATUS_SEARCHING 2
MRSa 0:97c748c69103 139 #define ANT_CHANNEL_STATUS_TRACKING 3
MRSa 0:97c748c69103 140
MRSa 0:97c748c69103 141 #define ANT_CAPABILITIES_NO_RECEIVE_CHANNELS 0x01
MRSa 0:97c748c69103 142 #define ANT_CAPABILITIES_NO_TRANSMIT_CHANNELS 0x02
MRSa 0:97c748c69103 143 #define ANT_CAPABILITIES_NO_RECEIVE_MESSAGE 0x04
MRSa 0:97c748c69103 144 #define ANT_CAPABILITIES_NO_TRANSMIT_MESSAGE 0x08
MRSa 0:97c748c69103 145 #define ANT_CAPABILITIES_NO_ACKD_MESSAGE 0x10
MRSa 0:97c748c69103 146 #define ANT_CAPABILITIES_NO_BURST_MESSAGE 0x20
MRSa 0:97c748c69103 147 #define ANT_CAPABILITIES_NETWORK_ENABLED 0x01
MRSa 0:97c748c69103 148 #define ANT_CAPABILITIES_SERIAL_NUMBER_ENABLED 0x04
MRSa 0:97c748c69103 149 #define ANT_CAPABILITIES_PER_CHANNEL_TX_POWER_ENABLED 0x10
MRSa 0:97c748c69103 150 #define ANT_CAPABILITIES_LOW_PRIORITY_SEARCH_ENABLED 0x20
MRSa 0:97c748c69103 151 #define ANT_CAPABILITIES_SCRIPT_ENABLED 0x40
MRSa 0:97c748c69103 152 #define ANT_CAPABILITIES_SEARCH_LIST_ENABLED 0x80
MRSa 0:97c748c69103 153 #define ANT_CAPABILITIES_LED_ENABLED 0x01
MRSa 0:97c748c69103 154 #define ANT_CAPABILITIES_EXT_MESSAGE_ENABLED 0x02
MRSa 0:97c748c69103 155 #define ANT_CAPABILITIES_SCAN_MODE_ENABLED 0x04
MRSa 0:97c748c69103 156 #define ANT_CAPABILITIES_PROX_SRARCH_ENABLED 0x10
MRSa 0:97c748c69103 157 #define ANT_CAPABILITIES_EXT_ASSIGN_ENABLED 0x20
MRSa 0:97c748c69103 158
MRSa 0:97c748c69103 159 #define ANT_DEVICE_SERIAL_NUMBER 0x61
MRSa 0:97c748c69103 160
MRSa 0:97c748c69103 161 #define ANT_PADDING_BYTE 0
MRSa 0:97c748c69103 162
MRSa 0:97c748c69103 163
MRSa 0:97c748c69103 164 namespace mbed {
MRSa 0:97c748c69103 165
MRSa 0:97c748c69103 166 class bc_ant
MRSa 0:97c748c69103 167 {
MRSa 0:97c748c69103 168 public:
MRSa 0:97c748c69103 169 bc_ant(PinName rx, PinName tx, PinName cts, int baud = 9600);
MRSa 0:97c748c69103 170
MRSa 0:97c748c69103 171 uint32_t ANT_UnAssignChannel( uint8_t Channel );
MRSa 0:97c748c69103 172 uint32_t ANT_AssignChannel( uint8_t Channel, uint8_t ChannelType, uint8_t NetworkNumber) ;
MRSa 0:97c748c69103 173 uint32_t ANT_AssignChannelExt( uint8_t Channel, uint8_t ChannelType, uint8_t NetworkNumber, uint8_t Extend );
MRSa 0:97c748c69103 174 uint32_t ANT_SetChannelId( uint8_t Channel, uint16_t DeviceNum, uint8_t DeviceType, uint8_t TransmissionType );
MRSa 0:97c748c69103 175 uint32_t ANT_SetChannelPeriod( uint8_t Channel, uint16_t MessaggePeriod );
MRSa 0:97c748c69103 176 uint32_t ANT_SetChannelPeriod_Hz( uint8_t Channel, uint16_t Period );
MRSa 0:97c748c69103 177 uint32_t ANT_SetChannelSearchTimeout( uint8_t ChannelNum, uint8_t SearcchTimeout );
MRSa 0:97c748c69103 178 uint32_t ANT_SetChannelRFFreq( uint8_t Channel, uint8_t RFFreq );
MRSa 0:97c748c69103 179 uint32_t ANT_SetNetworkKey( uint8_t NetworkNumber, uint8_t *pucKey);
MRSa 0:97c748c69103 180 uint32_t ANT_SetTransmitPower( uint8_t TransmitPower );
MRSa 0:97c748c69103 181 uint32_t ANT_AddChannelID( uint8_t Channel, uint16_t DeviceNum, uint8_t DeviceType, uint8_t TransmissionType, uint8_t ListIndex );
MRSa 0:97c748c69103 182 uint32_t ANT_ConfigList( uint8_t Channel, uint8_t ListSize, uint8_t Exclude );
MRSa 0:97c748c69103 183 uint32_t ANT_SetChannelTxPower( uint8_t Channel, uint8_t TxPower );
MRSa 0:97c748c69103 184 uint32_t ANT_SetLowPriorityChannelSearchTimeout( uint8_t ChannelNum, uint8_t SearchTimeout );
MRSa 0:97c748c69103 185 uint32_t ANT_SetSerialNumChannelId( uint8_t Channel, uint8_t DeviceType, uint8_t TransmissionType );
MRSa 0:97c748c69103 186 uint32_t ANT_RxExtMesgsEnable( uint8_t Enable );
MRSa 0:97c748c69103 187 uint32_t ANT_EnableLED( uint8_t Enable );
MRSa 0:97c748c69103 188 uint32_t ANT_CrystalEnable( uint8_t Enable );
MRSa 0:97c748c69103 189 uint32_t ANT_ConfigFrequencyAgility( uint8_t Channel, uint8_t Frequency1, uint8_t Frequency2, uint8_t Frequency3 );
MRSa 0:97c748c69103 190 uint32_t ANT_SetProximitySearch( uint8_t Channel, uint8_t SearchThreshold );
MRSa 0:97c748c69103 191 uint32_t ANT_SetUSBDescriptorString( uint8_t StringNum, uint8_t *pucDescString, uint8_t StringSize );
MRSa 0:97c748c69103 192 uint32_t ANT_ResetSystem ( void );
MRSa 0:97c748c69103 193 uint32_t ANT_OpenChannel(uint32_t Channel );
MRSa 0:97c748c69103 194 uint32_t ANT_CloseChannel(uint32_t Channel );
MRSa 0:97c748c69103 195 uint32_t ANT_RequestMessage(uint32_t Channel, uint8_t MessageID );
MRSa 0:97c748c69103 196 uint32_t ANT_OpenRxScanMode( void );
MRSa 0:97c748c69103 197 uint32_t ANT_SleepMessage( void );
MRSa 0:97c748c69103 198 uint32_t ANT_SendBroadcastData(uint8_t Channel, uint8_t * BroadcastData );
MRSa 0:97c748c69103 199 uint32_t ANT_SendBroadcastDataExt(uint8_t Channel, uint8_t *BroadcastData, uint16_t DeviceNumber, uint8_t DeviceType, uint8_t TransmissionType );
MRSa 0:97c748c69103 200 uint32_t ANT_SendAcknowledgedData(uint8_t Channel, uint8_t *BroadcastData );
MRSa 0:97c748c69103 201 uint32_t ANT_SendAcknowledgedDataExt( uint8_t Channel, uint8_t *BroadcastData, uint16_t DeviceNumber, uint8_t DeviceType, uint8_t TransmissionType );
MRSa 0:97c748c69103 202 uint32_t ANT_SendBurstTransferPacket( uint8_t ChannelSeq, uint8_t *BurstData );
MRSa 0:97c748c69103 203 uint32_t ANT_InitCWTestMode( void );
MRSa 0:97c748c69103 204 uint32_t ANT_SetCWTestMode( uint8_t TransmitPower, uint8_t RFChannel );
MRSa 0:97c748c69103 205 uint32_t ANT_SendExtBroadcastData( uint8_t Channel, uint16_t DeviceNum, uint8_t DeviceType, uint8_t TransmissionType, uint8_t *Data );
MRSa 0:97c748c69103 206 uint32_t ANT_SendExtAcknowledgedData( uint8_t Channel, uint16_t DeviceNum, uint8_t DeviceType, uint8_t TransmissionType, uint8_t *Data );
MRSa 0:97c748c69103 207 uint32_t ANT_SendExtBurstData( uint8_t Channel, uint16_t DeviceNum, uint8_t DeviceType, uint8_t TransmissionType, uint8_t *Data );
MRSa 0:97c748c69103 208
MRSa 0:97c748c69103 209
MRSa 0:97c748c69103 210 uint32_t BC_ANT_build_packet( uint8_t *souce, uint32_t size, uint8_t *dist );
MRSa 0:97c748c69103 211
MRSa 0:97c748c69103 212 uint32_t BC_ANT_ResetSystem( void );
MRSa 0:97c748c69103 213 uint32_t BC_ANT_OpenChannel( uint8_t Channel );
MRSa 0:97c748c69103 214 uint32_t BC_ANT_CloseChannel( uint8_t Channel );
MRSa 0:97c748c69103 215 uint32_t BC_ANT_RequestMessage( uint8_t Channel, uint8_t MessageID );
MRSa 0:97c748c69103 216
MRSa 0:97c748c69103 217 void attach(void(*fptr)(void), Serial::IrqType type = Serial::RxIrq);
MRSa 0:97c748c69103 218 uint32_t BC_ANT_RecvPacket(uint8_t *buffer, uint32_t size);
MRSa 0:97c748c69103 219
MRSa 0:97c748c69103 220 private:
MRSa 0:97c748c69103 221 uint32_t BC_ANT_SendPacket(uint8_t *packet, uint32_t size);
MRSa 0:97c748c69103 222
MRSa 0:97c748c69103 223 protected:
MRSa 0:97c748c69103 224 #define BC_ANT_BUFFSIZE 72
MRSa 0:97c748c69103 225 uint8_t BC_ANT_buffer[BC_ANT_BUFFSIZE];
MRSa 0:97c748c69103 226 uint8_t BC_ANT_raw_buffer[BC_ANT_BUFFSIZE];
MRSa 0:97c748c69103 227
MRSa 0:97c748c69103 228 Serial _serialPort;
MRSa 0:97c748c69103 229 DigitalIn _cts;
MRSa 0:97c748c69103 230
MRSa 0:97c748c69103 231 };
MRSa 0:97c748c69103 232
MRSa 0:97c748c69103 233 }
MRSa 0:97c748c69103 234 #endif /* ANT_H_ */