ATY_LIB V2_102_230218
ATY_LIB for general devices or ALGO
 
Loading...
Searching...
No Matches
main.c
Go to the documentation of this file.
1// Copyright 2021 IOsetting <iosetting(at)outlook.com>
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15/***
16 * Demo: Ci24R1 SOP8 2.4GHz RF
17 *
18 * Pin connection:
19 * P35(SS, Ignored) => CSN
20 * P34(MOSI) => DATA
21 * P32(SPCLK) => SCK
22 * VDD1 => 3.3V
23 * XC1,XC2 => 16MHz OSC
24 * GND => GND
25 *
26 * test-board: Minimum System; test-MCU: STC8H1K08,STC8H3K64S2
27 */
28
29#include "fw_hal.h"
30#include "ci24r1.h"
31
32// 0:TX, 1:RX
33#define CI24R1_MODE 1
34
35__CODE uint8_t TX_ADDRESS[5]={0x34,0x43,0x10,0x10,0x01};
36__CODE uint8_t RX_ADDRESS[5]={0x01,0x43,0x10,0x10,0x34};
37extern uint8_t *xbuf_data;
38
39void GPIO_Init(void)
40{
41 // SCLK(P32) CSN(P35)
43}
44
45int main(void)
46{
47 __CODE uint8_t tmp[] = {
48 0x1F, 0x80, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
49 0x21, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x28,
50 0x31, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x38,
51 0x41, 0x12, 0x13, 0x14, 0x15, 0x16, 0x37, 0x48};
52 uint8_t i, j, status;
53
55 GPIO_Init();
56
57 // UART1, baud 115200, baud source Timer1, 1T mode, no interrupt
59 UART1_TxString("UART Initialized\r\n");
60
61 while (CI24R1_SPI_Test() == HAL_ERROR)
62 {
63 UART1_TxString(" - check failed\r\n");
64 SYS_Delay(1000);
65 }
66 UART1_TxString(" - check passed\r\n");
67
69
70 if (CI24R1_MODE == 0)
71 {
72 // TX
77 UART1_TxString("CI24R1 TX Initialized\r\n");
78
79 while(1)
80 {
83 SYS_Delay(500);
84 }
85 }
86 else
87 {
88 // RX
93 UART1_TxString("CI24R1 RX Initialized\r\n");
94
95 while(1)
96 {
98 CI24R1_Rx();
99 UART1_TxString("\r\n");
100 SYS_Delay(10);
101 }
102 }
103}
void CI24R1_SetTxAddress(uint8_t *address)
Definition: ci24r1.c:146
void CI24R1_SetChannel(uint8_t channel)
Definition: ci24r1.c:157
void CI24R1_SetTxMode(void)
Definition: ci24r1.c:116
uint8_t CI24R1_Tx(uint8_t *ucPayload, uint8_t length)
Definition: ci24r1.c:193
void CI24R1_SetRxAddress(uint8_t *address)
Definition: ci24r1.c:152
void CI24R1_SetRxMode(void)
Definition: ci24r1.c:124
uint8_t CI24R1_Rx(void)
Definition: ci24r1.c:217
void CI24R1_Init(void)
Definition: ci24r1.c:163
uint8_t CI24R1_SPI_Test(void)
Definition: ci24r1.c:132
uint8_t CI24R1_PrintStatus(void)
Definition: ci24r1.c:269
#define CI24R1_PLOAD_WIDTH
Definition: ci24r1.h:21
#define GPIO_P3_SetMode(__PINS__, __MODE__)
Definition: fw_gpio.h:89
@ GPIO_Pin_5
Definition: fw_gpio.h:50
@ GPIO_Pin_2
Definition: fw_gpio.h:47
@ GPIO_Mode_Output_PP
Definition: fw_gpio.h:24
void SYS_SetClock(void)
Definition: fw_sys.c:40
void SYS_Delay(uint16_t t)
Definition: fw_sys.c:65
@ HAL_ERROR
Definition: fw_types.h:77
@ HAL_State_ON
Definition: fw_types.h:71
unsigned char uint8_t
Definition: fw_types.h:18
void UART1_TxString(uint8_t *str)
Definition: fw_uart.c:85
@ UART1_BaudSource_Timer1
Definition: fw_uart.h:33
void UART1_Config8bitUart(UART1_BaudSource_t baudSource, HAL_State_t _1TMode, uint32_t baudrate)
Definition: fw_uart.c:56
uint8_t * xbuf_data
Definition: ci24r1.c:18
__CODE uint8_t TX_ADDRESS[5]
Definition: main.c:35
int main(void)
Definition: main.c:45
void GPIO_Init(void)
Definition: main.c:39
__CODE uint8_t RX_ADDRESS[5]
Definition: main.c:36
#define CI24R1_MODE
Definition: main.c:33
uint8_t __XDATA i