- The added line is THIS COLOR.
- The deleted line is THIS COLOR.
[[ANT]]
* Library for LPC1114 [#a440fa7b]
>
This is a sample code of the library for LPC1114, a 32bit microcontroller (IC) produced by NXP Semiconductors. (The product page at NXP Semiconductors is available [[here>http://www.nxp.com/products/microcontrollers/cortex_m0/lpc1100_x_l/#overview]].)~
>
This library is still alpha version, and there is possibly a lot bug in the code. (Please handle it carefully)~
>
ant.c calls functions listed at uart.c. The functions are used for exchnaging commands and results with the ANT chip. In this sample, therefore, uart.c as well as uart.h are required.~
>>
For uart.c and uart.h, their licenses are checking right now.~
For uart.c and uart.h, their licenses are checking right now.
- header file
- C source file
>
- header file &ref(ant.h);~
- C source file &ref(ant.c);~
** Example [#n9172ee0]
>
#include <ant.h>
#include <uart.h>
#define DEVICE_NUMBER 31
#define MAX_BUFSIZE 32
#define ANT_CH 0
unsigned char buffer[MAX_BUFSIZE];
void OpenANT() {
// 0ch に通信パラメータを設定して、チャンネルをオープンする関数
ANT_ResetSystem(); // ANT デバイスをリセットする
ANT_AssignChannel( ANT_CH, ANT_Bidirectional_Slave, 0) ; // 受信用チャンネルとしてアサインする
ANT_SetChannelId( ANT_CH, DEVICE_NUMBER, 1, 1 ); // デバイス番号等のIDをセットする
ANT_SetChannelPeriod_Hz( ANT_CH, 4 ); // チャンネルピリオド 4Hzに設定 (デフォルトと同じなので省略可能)
ANT_SetChannelRFFreq( ANT_CH, 4 ); // 送受信する周波数を 2404MHz に設定する
ANT_OpenChannel( ANT_CH ); // チャンネルを開いて通信を開始する
// This function sets the communication parameter 0 and opens the communication channel.
ANT_ResetSystem(); // Resetting ANT device
ANT_AssignChannel( ANT_CH, ANT_Bidirectional_Slave, 0) ; // Assigning a channel to a receiving channel
ANT_SetChannelId( ANT_CH, DEVICE_NUMBER, 1, 1 ); // Setting Device Number and other Device ID
ANT_SetChannelPeriod_Hz( ANT_CH, 4 ); // Setting Channel Period as 4Hz (This is the default setting. )
ANT_SetChannelRFFreq( ANT_CH, 4 ); // Frequency is at 2404MHz
ANT_OpenChannel( ANT_CH ); // Opening a channel and starting communication
return;
}
void main () {
void main () {
int s;
OpenANT();
while(1) {
if ( s = BC_ANT_RecvPacket( buffer, MAX_BUFSIZE )) {
// ANTチップからのデータ受信時の処理...
// パケットを受信したときや ANTチップからのイベントの処理を記述します
// Receiving data from the ANT chip, and processing....
// Receiving packets, and processing events, which the ANT chip has sent .
}
}
}
* Revision History [#bbddba0e]
>
- 2013/02/01 This article is initially uploaded