< p>
Initialize the serial port (usart): Read the source code:
typedef struct
{
uint32_t USART_BaudRate;
uint16_t USART_WordLength;
uin t16_t USART_StopBits;
uint16_t USART_Parity;
uint16_t USART_Parity; 18pt “> uint16_t USART_Mode;
uint16_t USART_HardwareFlowControl;
} USART_InitTypeDef;
encapsulates the initialization state of the serial port into a structure, just like the GPIO module, first Define such a structure type, initialize the value, call this function
void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct)
USART_TypeDef* USARTx is a structure pointer, which points to the first address of USART. The memory byte of the structure is aligned with the address of the register.
typedef struct
{
__IO uint16_t SR;
uint16_t RESERVED0; //It is used for padding, because of the C language structure memory alignment principle. Otherwise, it will not correspond to the register one by one.
__IO uint16_t DR; //Look at the register address map of USART to enhance understanding.
uint16_t RESERVED1;
__IO uint16_t BRR;
uint16_t RESERVED2;
__IO uint16_t CR1;
uint16_t RESERVED3;
__IO uint16_t CR2;
uint16_t RESERVED4;
__IO uint16_t CR3;
uint16_t RESERVED5;
< span style="font-size: 18pt"> __IO uint16_t GTPR;
uint16_t RESERVED6;
< div> } USART_TypeDef; USART_TypeDef; //At this time, you will experience the beauty of the C language, which is just right.
Open the serial port and accept interruption:
Enable serial port one:
write serial port interrupt function:
Send data from serial port: USART_SendData(USART_TypeDef* USARTx, uint16_t Data) ///
< span style="font-size: 18pt">
1.2:Interrupt Vector Controller (NVIC): Set interrupt priority: preempt priority and sub-priority; before using interrupt, first set priority grouping and configure NVIC.
1.3: outside of SPI Set the module to use: Read the source code & manual:
Enable the spi peripheral (under APB1), first enable the peripheral module clock (and The serial port routines are almost the same) The pin should be reused to configure the GPIO mode. Initialization Finally, the peripheral modules are enabled.
SPI1-SPI3 SPI1 and SPI3 support remapping, SPI2 does not support remapping, the default is PB12-PB15 (chip select, SCK, SPI2_MISO , SPI2_MOSI) io configuration:
51 The single-chip microcomputer simulates the SPI timing operation ds1302 (software simulation) through the timing diagram to simulate the timing, read (write) the data by positioning, shift, pay attention to the high and low bits
typedef struct
{
uint16_t SPI_Direction; /*!< Specifies the SPI unidirectional or bidirectional data mode. One-way two-way data mode
This parameter can be a value of @ref SPI_data_direction */ div
uint16_t SPI_Mode; SPI_Mode; /*! < Specifies the SPI operating mode. Master-slave mode
This parameter can be a value of @ref SPI_mode */ div>
uint16_t SPI_DataSize; /*!
This parameter can be a value of @ref SPI_data_size */8 or 16 bits
This parameter can be a value of @ref SPI_Clock_Polarity */low level of the clock span>
uint16_t SPI_CPHA; /*!
Change from the first or the second time when the data is sampled div div
uint16_t SPI_NSS; /*!
This parameter can be a value of ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ size: 16px”> uint16_t SPI_BaudRatePrescaler;
To uint 16 _ t SPI_BaudRatePrescaler; div>
To To in, div>
u sed to configure the transmit and receive SCK clock.This parameter can be a value of @ref [email protected] The communication clock is derived from the masterclock. The slave clock does not need to be set. * /// baud < /span>
uint16_t SPI_FirstBit; /*!
This parameter can be a value of @ref SPI_MSB_LSB
font-size: 16px”>uint16_t SPI_CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation. */
}SPI_InitTypeDef ;
2.1: First understand Pixy’s serial protocol: SPI communication , Set in the Data Out Port option:
< /p>
One data is 16 bits, 7 data, a total of 14 bytes of data.
01 00 9B 00 7B 00 A4 00 23 00 55 AA 3A 01 01 00 EE 00 1F 00 1C 00 10 00 55 AA 55 AA
DC 01 01 00 9B 00 7E 00 A5 00 1D 00 55 AA 39 01 01 00 EE 00 20 00 1D 00 0D 00 55 AA
9A 00 7E 00 A5 00 1F 00 55 AA 36 01 01 00 EE 00 1E 00 1C 00 0D 00 55 AA 55 AA E4 01
A2 00 1F 00 55 AA 37 01 01 00 EE 00 1F 00 1C 00 0D 00 55 AA 55 AA D9 01 01 00 9B 00
These strings of data waste 4 days of my time. It’s a pitfall. Note that SPI and the serial port read out the data start flag data is different,
learn to configure pixy with the host computer. Use the spi protocol to read out the data and send it to the serial port:
2.4: Processing data:
If you need to remap and configure the AFIO register; take the serial port one as Example: AFIO_MAPR register
Initialize the serial port (usart): Read the source code:
< span style="font-size: 18pt">typedef struct
{
uint32_t USART_BaudRate;
uint16_t USART_WordLength;
uint16_t USART_StopBits; uint16_t USART_StopBits;
uint16_t USART_Parity;
div> uint16_t USART_Mode;
uint16_t USART_HardwareFlowControl;
} USART_InitTypeDef;
encapsulates the initialization state of the serial port into A structure, just like the GPIO module, first define such a structure type, assign and initialize, call this function
void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct)
USART_TypeDef* USARTx is a structure pointer, which points to USART The first address, the memory byte alignment of the structure, and the address of the register one-to-one correspondence
typedef struct
{
__IO uint16_t SR; div>
uint16_t RESERVED0; //It is used for padding, because of the C language structure memory alignment principle. Otherwise, it will not correspond to the register one by one.
__IO uint16_t DR; //Look at the register address map of USART to enhance understanding.
uint16_t RESERVED1;
__IO uint16_t BRR;
uint16_t RESERVED2;
__IO uint16_t CR1;
uint16_t RESERVED3;
__IO uint16_t CR2;
uint16_t RESERVED4;
__IO uint16_t CR3;
uint16_t RESERVED5;
< span style="font-size: 18pt"> __IO uint16_t GTPR;
uint16_t RESERVED6;
< div> } USART_TypeDef; U .
Open the serial port and accept interruption:
Enable serial port one:
write serial port interrupt function:
Send data from serial port: USART_SendData(USART_TypeDef* USARTx, uint16_t Data) ///
< span style="font-size: 18pt">
1.2:Interrupt Vector Controller (NVIC): Set interrupt priority: preempt priority and sub-priority; before using interrupt, first set priority grouping and configure NVIC.
1.3: outside of SPI设模块使用:阅读源码&手册:
使能spi外设(APB1下)先使能外设模块时钟(和串口的套路差不多)pin要复用配置好GPIO的模式。初始化 最后使能外设模块。
SPI1-SPI3 SPI1和SPI3支持重映射,SPI2不支持重映射,默认PB12-PB15 (片选,SCK,SPI2_MISO,SPI2_MOSI)io配置:
51单片机模拟SPI时序操作ds1302(软件模拟)通过时序图模拟时序,通过位于,移位读出(写入)数据,注意高低位
typedef struct
{
uint16_t SPI_Direction; /*!< Specifies the SPI unidirectional or bidirectional data mode.单向双向数据模式
This parameter can be a value of @ref SPI_data_direction */
uint16_t SPI_Mode; /*!< Specifies the SPI ope rating mode. 主从模式
This parameter can be a value of @ref SPI_mode */
uint16_t SPI_DataSize; /*!< Specifies the SPI data size.
This parameter can be a value of @ref SPI_data_size */8或16位
uint16_t SPI_CPOL; /*!< Specifies the serial clock steady state.
This parameter can be a value of @ref SPI_Clock_Polarity */ //时钟的高低电平
uint16_t SPI_CPHA; /*!< Specifies the clock active edge for the bit capture.
This parameter can be a value of @ref SPI_Clock_Phase *///数据采样时从第一个还是第二个时 钟跳变开始
uint16_t SPI_NSS; /*!< Specifies whether the NSS signal is managed by
hardware (NSS pin) or by software using the SSI bit. This parameter can be a value of @ref SPI_Slave_Select_management */ //片选
uint16_t SPI_BaudRatePrescaler;
/*!< Specifies the Baud Rate prescaler value whch will be
used to configure the transmit and receive SCK clock.This p arameter can be a value of @ref [email protected] The communication clock is derived from the masterclock. The slave clock does not need to be set. *///波特率
uint16_t SPI_FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit.第一位是最高位还是最低位
This parameter can be a value of @ref SPI_MSB_LSB_transmission */
uint16_t SPI_CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation. */
}SPI_InitTypeDef;
2.1:先明白Pixy的串行协议:SPI通信,在Data Out Port选项中设置:
一个数据16位,7个数据,共14字节的数据。
01 00 9B 00 7B 00 A4 00 23 00 55 AA 3A 01 01 00 EE 00 1F 00 1C 00 10 00 55 AA 55 AA
DC 01 01 00 9B 00 7E 00 A5 00 1D 00 55 AA 39 01 01 00 EE 00 20 00 1D 00 0D 00 55 AA
9A 00 7E 00 A5 00 1F 00 55 AA 36 01 01 00 EE 00 1E 00 1C 00 0D 00 55 AA 55 AA E4 01
A2 00 1F 00 55 AA 37 01 01 00 EE 00 1F 00 1C 00 0D 00 55 AA 55 AA D9 01 01 00 9B 00
这几串数据浪费了我4天时间,真坑。注意SPI与串口读出的数据开始标志数据不同,
学会用上位机配置好pixy。使用spi协议读出数据发给串口:
2.4:处理数据:
typedef struct
{
uint32_t USART_BaudRate;
uint16_t USART_Wo rdLength;
uint16_t USART_StopBits;
uint16_t USART_Parity;
uint16_t USART_Mode;
uint16_t USART_HardwareFlowControl;
} USART_InitTypeDef;
将串口的初始化的状态封装成一个结构体,就像GPIO模块那样,自己先定义这样一个结构体类型,赋值初始化,调用此函数
void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct)
USART_TypeDef* USARTx是一个结构体指针,它指向USART的首地址,结构体的内存字节对齐,和寄存器的地址一一对应
typedef struct
{
__ IO uint16_t SR;
uint16_t RESERVED0; //填充用的,因为C语言结构体内存对齐原则。不然就和寄存器一一不对应了。
__IO uint16_t DR; //这里看看USART的寄存器地址映射图增强理解。
uint16_t RESERVED1;
__IO uint16_t BRR;
uint16_t RESERVED2;
__IO uint16_t CR1;
uint16_t RESERVED3;
__IO uint16_t CR2;
uint16_t RESERVED4;
__IO uint16_t CR3;
uint16_t RESERVED5;
__IO uint16_t GTPR;
uint16_t RESERVED6;
} USART_TypeDef; //此时你会体会到C语言的美感,恰到好处。
开启串口一接受中断:
使能串口一:
编写串口中断函数:
串口发送数据:USART_SendData(USART_TypeDef* USARTx, uint16_t Data) //
1.2:中断向量控制器(NVIC):设置中断优先级:抢占优先级和子优先级;使用中断前,先要设置优先级分组,配置NVIC。
1.3:SPI外设模块使用:阅读源码&手册:
使能spi外设(APB1下)先使能外设模块时钟(和串口的套路差不多)pin要复用配置好GPIO的模式。初始化 最后使能外设模块。
SPI1-SPI3 SPI1和SPI3支持重映射,SPI2不支持重映射,默认PB12-PB15 (片选,SCK,SPI2_MISO,SPI2_MOSI)io配置:
51单片机模拟SPI时序操作ds1302(软件模拟)通过时序图模拟时序,通过位于,移位读出(写入)数据,注意高低位
typedef struct
{
uint16_t SPI_Direction; /*!< Specifies the SPI unidirectional or bidirectional data mode.单向双向数据模式
This parameter can be a value of @ref SPI_data_direction */
uint16_t SPI_Mode; /*!< Specifies the SPI operating mode. 主从模式
This parameter can be a value of @ref SPI_mode */
uint16_t SPI_DataSize; /*!< Specifies the SPI data size.
This parameter can be a value of @ref SPI_data_size */8或16位
uint16_t SPI_CPOL; /*!< Specifies the serial clock steady state.
This parameter can be a value of @ref SPI_Clock_Polarity */ //时钟的高低电平
uint16_t SPI_CPHA; /*!< Specifies the clock active edge for the bit capture.
This param eter can be a value of @ref SPI_Clock_Phase *///数据采样时从第一个还是第二个时 钟跳变开始
uint16_t SPI_NSS; /*!< Specifies whether the NSS signal is managed by
hardware (NSS pin) or by software using the SSI bit. This parameter can be a value of @ref SPI_Slave_Select_management */ //片选
uint16_t SPI_BaudRatePrescaler;
/*!< Specifies the Baud Rate prescaler value whch will be
used to configure the transmit and receive SCK clock.This parameter can be a value of @ref [email protected] The communication clock is derived from the masterclock. The slave clock does not need to be set. *///波特率
uint16_t SPI_FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit.第一位是最高位还是最低位
This parameter can be a value of @ref SPI_MSB_LSB_transmission */
uint16_t SPI_CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation. */
}SPI_InitTypeDef;
2.1:先明白Pixy的串行协议:SPI通信,在Data Out Port选项中设置:
一个数据16位,7个数据,共14字节的数据。
01 00 9B 00 7B 00 A4 00 23 00 55 AA 3A 01 01 00 EE 00 1F 00 1C 00 10 00 55 AA 55 AA
DC 01 01 00 9B 00 7E 00 A5 00 1D 00 55 AA 39 01 01 00 EE 00 20 00 1D 00 0D 00 55 AA
9A 00 7E 00 A5 00 1F 00 55 AA 36 01 01 00 EE 00 1E 00 1C 00 0D 00 55 AA 55 AA E4 01
A2 00 1F 00 55 AA 37 01 01 00 EE 00 1F 00 1C 00 0D 00 55 AA 55 AA D9 01 01 00 9B 00
这几串数据浪费了我4天时间,真坑。注意SPI与串口读出的数据开始标志数据不同,
学会用上位机配置好pixy。使用spi协议读出数据发给串口:
2.4:处理数据:
typedef struct
{
uint32_t USART_BaudRate;
uint16_t USART_WordLength;
uint16_t USART_StopBits;
uint16_t USART_Parity;
uint16_t USART_Mode;
uint16_t USART_HardwareFlowControl;
} USART_InitTypeDef;
将串口的初始化的状态封装成一个结构体,就像GPIO模块那样,自己先定义这样一个结构体类型,赋值初始化,调用此函数
void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct)
USART_TypeDef* USARTx是一个结构体指针,它指向USART的首地址,结构体的内存字节对齐,和寄存器的地址一一对应
typedef struct
{
__IO uint16_t SR;
uint16_t RESERVED0; //填充用的,因为C语言结构体内存对齐原but.不然就和寄存器一一不对应了。
__IO uint16_t DR; //这里看看USART的寄存器地址映射图增强理解。
uint16_t RESERVED1;
__IO uint16_t BRR;
uint16_t RESERVED2;
__IO uint16_t CR1;
uint16_t RESERVED3;
__IO uint16_t CR2;
uint16_t RESERVED4;
__IO uint16_t CR3;
uint16_t RESERVED5;
__IO uint16_t GTPR;
uint16_t RESERVED6;
} USART_TypeDef; //此时你会体会到C语言的美感,恰到好处。
开启串口一接受中断:
使能串口一:
编写串口中断函数:
串口发送数据:USART_SendData(USART_TypeDef* USARTx, uint16_t Data) //
1.2:中断向量控制器(NVIC):设置中断优先级:抢占优先级和子优先级;使用中断前,先要设置优先级分组,配置NVIC。
1.3:SPI外设模块使用:阅读源码&手册:
使能spi外设(APB1下)先使能外设模块时钟(和串口的套路差不多)pin要复用配置好GPIO的模式。初始化 最后使能外设模块。
SPI1-SPI3 SPI1和SPI3支持重映射,SPI2不支持重映射,默认PB12-PB15 (片选,SCK,SPI2_MISO,SPI2_MOSI)io配置:
51单片机模拟SPI时序操作ds1302(软件模拟)通过时序图模拟时序,通过位于,移位读出(写入)数据,注意高低位
typedef struct
{
uint16_t SPI_Direction; /*!< Specifies the SPI unidirectional or bidirectional data mode.单向双向数据模式
This parameter can be a value of @ref SPI_data_direction */
uint16_t SPI_Mode; /*!< Specifies the SPI operating mode. 主从模式
This parameter can be a value of @ref SPI_mode */
uint16_t SPI_DataSize; /*!< Specifies the SPI data size.
This parameter can be a value of @ref SPI_data_size */8或16位
uint16_t SPI_CPOL; /*!< Specifies the serial clock steady state.
This parameter can be a value of @ref SPI_Clock_Polarity */ //时钟的高低电平
uint16_t SPI_CPHA; /*!< Specifies the clock active edge for the bit capture.
This parameter can be a value of @ref SPI_Clock_Phase *///数据采样时从第一个还是第二个时 钟跳变开始
uint16_t SPI_NSS; /*!< Specifies whether the NSS signal is managed by
hardware (NSS pin) or by software using the SSI bit. This parameter can be a value of @ref SPI_Slave_Select_management */ //片选
uint16_t SPI_BaudRatePrescaler;
/*!< Specifies the Baud Rate prescaler value whch will be
used to configure the transmit and receive SCK clock.This parameter can be a value of @ref [email protected] The communication clock is derived from the masterclock. The slave clock does not need to be set. *///波特率
uint16_t SPI_FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit.第一位是最高位还是最低位
This parameter can be a value of @ref SPI_MSB_LSB_transmission */
uint16_t SPI_CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation. */
}SPI_InitTypeDef;
2.1:先明白Pixy的串行协议:SPI通信,在Data Out Port选项中设置:
一个数据16位,7个数据,共14字节的数据。
01 00 9B 00 7B 00 A4 00 23 00 55 AA 3A 01 01 00 EE 00 1F 00 1C 00 10 00 55 AA 55 AA
DC 01 01 00 9B 00 7E 00 A5 00 1D 00 55 AA 39 01 01 00 EE 00 20 00 1D 00 0D 00 55 AA
9A 00 7E 00 A5 00 1F 00 55 AA 36 01 01 00 EE 00 1E 00 1C 00 0D 00 55 AA 55 AA E4 01
A2 00 1F 00 55 AA 37 01 01 00 EE 00 1F 00 1C 00 0D 00 55 AA 55 AA D9 01 01 00 9B 00
这几串数据浪费了我4天时间,真坑。注意SPI与串口读出的数据开始标志数据不同,
学会用上位机配置好pixy。使用spi协议读出数据发给串口:
2.4:处理数据:
USART_TypeDef* USARTx是一个结构体指针,它指向USART的首地址,结构体的内存字节对齐,和寄存器的地址一一对应
typedef struct
{
__IO uint16_t SR;
uint16_t RESERVED0; //填充用的,因为C语言结构体内存对齐原则。不然就和寄存器一一不对应了。
__IO uint16_t DR; //这里看看USART的寄存器地址映射图增强理解。
uint16_t RESERVED1;
__IO uint16_t BRR;
uint16_t RESERVED2;
__IO uint16_t CR1;
uint16_t RESERVED3;
__IO uint16_t CR2;
uint16_t RESERVED4;
__IO uint16_t CR3;
uint16_t RESERVED5;
__IO uint16_t GTPR;
uint16_t RESERVED6;
} USART_TypeDef; //此时你会体会到C语言的美感,恰到好处。
开启串口一接受中断:
使能串口一:
编写串口中断函数:
串口发送数据:USART_SendData(USART_TypeDef* USARTx, uint16_t Data) //
1.2:中断向量控制器(NVIC):设置中断优先级:抢占优先级和子优先级;使用中断前,先要设置优先级分组,配置NVIC。
1.3:SPI外设模块使用:阅读源码&手册:
使能spi外设(APB1下)先使能外设模块时钟(和串口的套路差不多)pin要复用配置好GPIO的模式。初始化 最后使能外设模块。
SPI1-SPI3 SPI1和SPI3支持重映射,SPI2不支持重映射,默认PB12-PB15 (片选,SCK,SPI2_MISO,SPI2_MOSI)io配置:
51单片机模拟SPI时序操作ds1302(软件模拟)通过时序图模拟时序,通过位于,移位读出(写入)数据,注意高低位
typedef struct
{
uint16_t SPI_Direction; /*!< Specifies the SPI unidirectional or bidirectional data mode.单向双向数据模式
This parameter can be a value of @ref SPI_data_direction */
uint16_t SPI_Mode; /*!< Specifies the SPI operating mode. 主从模式
This parameter can be a value of @ref SPI_mode */
uint16_t SPI_DataSize; /*!< Specifies the SPI data size.
This parameter can be a value of @ref SPI_data_size */8或16位
uint16_t SPI_CPOL; /*!< Specifies the serial clock steady state.
This parameter can be a value of @ref SPI_Clock_Polarity */ //时钟的高低电平
uint16_t SPI_CPHA; /*!< Specifies the clock active edge for the bit capture.
This parameter can be a value of @ref SPI_Clock_Phase *///数据采样时从第一个还是第二个时 钟跳变开始
uint16_t SPI_NSS; /*!< Specifies whether the NSS signal is managed by
hardware (NSS pin) or by software using the SSI bit. This parameter can be a value of @ref SPI_Slave_Select_management */ //片选
uint16_t SPI_BaudRatePrescaler;
/*!< Specifies the Baud Rate prescaler value whch will be
used to configure the transmit and receive SCK clock.This parameter can be a value of @ref [email protected] The communication clock is derived from the masterclock. The slave clock does not need to be set. *///波特率
uint16_t SPI_FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit.第一位是最高位还是最低位
This parameter can be a value of @ref SPI_MSB_LSB_transmission */
uint16_t SPI_CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation. */
}SPI_InitTypeDef;
2.1:先明白Pixy的串行协议:SPI通信,在Data Out Port选项中设置:
一个数据16位,7个数据,共14字节的数据。
01 00 9B 00 7B 00 A4 00 23 00 55 AA 3A 01 01 00 EE 00 1F 00 1C 00 10 00 55 AA 55 AA
DC 01 01 00 9B 00 7E 00 A5 00 1D 00 55 AA 39 01 01 00 EE 00 20 00 1D 00 0D 00 55 AA
9A 00 7E 00 A5 00 1F 00 55 AA 36 01 01 00 EE 00 1E 00 1C 00 0D 00 55 AA 55 AA E4 01
A2 00 1F 00 55 AA 37 01 01 00 EE 00 1F 00 1C 00 0D 00 55 AA 55 AA D9 01 01 00 9B 00
这几串数据浪费了我4天时间,真坑。注意SPI与串口读出的数据开始标志数据不同,
学会用上位机配置好pixy。使用spi协议读出数据发给串口:
2.4:处理数据:
typedef struct
{
uint16_t SPI_Direction; /*!< Specifies the SPI unidirectional or bidirectional data mode.单向双向数据模式
This parameter can be a value of @ref SPI_data_direction */
uint16_t SPI_Mode; /*!< Specifies the SPI operating mode. 主从模式
This parameter can be a value of @ref SPI_mode */
uint16_t SPI_DataSize; /*!< Specifies the SPI data size.
This parameter can be a value of @ref SPI_data_size */8或16位
uint16_t SPI_CPOL; /*!< Specifies the serial clock steady state.
This parameter can be a value of @ref SPI_Clock_Polarity */ //时钟的高低电平
uint16_t SPI_CPHA; /*!< Specifies the clock activ e edge for the bit capture.
This parameter can be a value of @ref SPI_Clock_Phase *///数据采样时从第一个还是第二个时 钟跳变开始
uint16_t SPI_NSS; /*!< Specifies whether the NSS signal is managed by
hardware (NSS pin) or by software using the SSI bit. This parameter can be a value of @ref SPI_Slave_Select_management */ //片选
uint16_t SPI_BaudRatePrescaler;
/*!< Specifies the Baud Rate prescaler value whch will be
used to configure the transmit and receive SCK clock.This param eter can be a value of @ref [email protected] The communication clock is derived from the masterclock. The slave clock does not need to be set. *///波特率
uint16_t SPI_FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit.第一位是最高位还是最低位
This parameter can be a value of @ref SPI_MSB_LSB_transmission */
uint16_t SPI_CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation. */
}SPI_InitTypeDef;
一个数据16位,7个数据,共14字节的数据。
01 00 9B 00 7B 00 A4 00 23 00 55 AA 3A 01 01 00 EE 00 1F 00 1C 00 10 00 55 AA 55 AA
DC 01 01 00 9B 00 7E 00 A5 00 1D 00 55 AA 39 01 01 00 EE 00 20 00 1D 00 0D 00 55 AA
9A 00 7E 00 A5 00 1F 00 55 AA 36 01 01 00 EE 00 1E 00 1C 00 0D 00 55 AA 55 AA E4 01
A2 00 1F 00 55 AA 37 01 01 00 EE 00 1F 00 1C 00 0D 00 55 AA 55 AA D9 01 01 00 9B 00
这几串数据浪费了我4天时间,真坑。注意SPI与串口读出的数据开始标志数据不同,
学会用上位机配置好pixy。使用spi协议读出数据发给串口:
2.4:处理数据:
一个数据16位,7个数据,共14字节的数据。
01 00 9B 00 7B 00 A4 00 23 00 55 AA 3A 01 01 00 EE 00 1F 00 1C 00 10 00 55 AA 55 AA
DC 01 01 00 9B 00 7E 00 A5 00 1D 00 55 AA 39 01 01 00 EE 00 20 00 1D 00 0D 00 55 AA
9A 00 7E 00 A5 00 1F 00 55 AA 36 01 01 00 EE 00 1E 00 1C 00 0D 00 55 AA 55 AA E4 01
A2 00 1F 00 55 AA 37 01 01 00 EE 00 1F 00 1C 00 0D 00 55 AA 55 AA D9 01 01 00 9B 00
01 00 9B 00 7B 00 A4 00 23 00 55 AA 3A 01 01 00 EE 00 1F 00 1C 00 10 00 55 AA 55 AA
DC 01 01 00 9B 00 7E 00 A5 00 1D 00 55 AA 39 01 01 00 EE 00 20 00 1D 00 0D 00 55 AA
9A 00 7E 00 A5 00 1F 00 55 AA 36 01 01 00 EE 00 1E 00 1C 00 0D 00 55 AA 55 AA E4 01
A2 00 1F 00 55 AA 37 01 01 00 EE 00 1F 00 1C 00 0D 00 55 AA 55 AA D9 01 01 00 9B 00
这几串数据浪费了我4天时间,真坑。注意SPI与串口读出的数据开始标志数据不同,
学会用上位机配置好pixy。使用spi协议读出数据发给串口:
2.4:处理数据:
学会用上位机配置好pixy。使用spi协议读出数据发给串口:
2.4:处理数据:
接下来用读到的pixy的数据就做你想做的事了。