平台是STM32F103CRT6,记个笔记加深自己对指针数组的理解
#include "includes.h"
#include "crc.h"
extern unsigned char RX_Data[9]; //½ÓÊÕµ½µÄÊý¾Ý
u8 i=0;
unsigned char a= 0x0A;
unsigned char *b = "zhongli"; //ĬÈÏ·¢ËÍ×Ö·û´®
unsigned char c[] = "yunjin" ;
unsigned int d; //CRCУÑé
unsigned char buffer[9];
unsigned char *buffer1;
unsigned int flag = 0; //½ÓÊÜÊý¾Ý±ê±êÖ¾
int main()
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //ÉèÖÃNVICÖжϷÖ×é2:2λÇÀÕ¼ÓÅÏȼ¶£¬2λÏìÓ¦ÓÅÏȼ¶
delay_init(); //ÑÓʱº¯Êý³õʼ»¯
TIM4_Init(9,7199);//Tout£¨Òç³öʱ¼ä£©=£¨ARR+1)(PSC+1)/Tclk =10*7200/72000000s=1ms
LED_Init();
USART1_Init(115200,0); //´®¿Ú³õʼ»¯Îª115200
delay_us(500);
NRF24L01_Init(); //³õʼ»¯NRF24L01
while(1)
{
if(flag )
{
b = &(RX_Data[2]);
flag = 0;
}
i = 0 ;
while(b[i] != '\0')
{
buffer[i] = b[i];
i++;
}
d = MBCRC16(b,i);
buffer[7]= (d&0xFF);
buffer[8] = ((d&0xFF00)>>8);
UartPutStr(buffer,sizeof(buffer));
delay_ms(500);
UART_Putchar(a);
}
}
|