void TM_NRF24L01_GetData(uint8_t* data) {
	/* Pull down chip select */
	NRF24L01_CSN_LOW;
	/* Send read payload command*/
	TM_SPI_Send(NRF24L01_SPI, NRF24L01_R_RX_PAYLOAD_MASK);
	/* Read payload */
	TM_SPI_SendMulti(NRF24L01_SPI, data, data, TM_NRF24L01_Struct.PayloadSize);
	/* Pull up chip select */
	NRF24L01_CSN_HIGH;
	
	/* Reset status register, clear RX_DR interrupt flag */
	TM_NRF24L01_WriteRegister(NRF24L01_REG_STATUS, (1 << NRF24L01_RX_DR));
}
コード例 #2
0
ファイル: main.c プロジェクト: MaJerle/stm32f429
int main(void) {
	/* Initialize system */
	SystemInit();
	
	/* Initialize delay */
	TM_DELAY_Init();
	
	/* Init SPI */
	TM_SPI_Init(SPI1, TM_SPI_PinsPack_1);
	
	/* Init SPI DMA */
	TM_SPI_DMA_Init(SPI1);
	
	/* Set fake SPI TX buffer */
	memset(TX_Buffer, 0x00, sizeof(TX_Buffer));
	
	val = TM_GENERAL_DWTCounterEnable();
	
	/* Set CS low first here before you send data over SPI */
	
	
	TM_GENERAL_DWTCounterSetValue(0);
	/* Send data over SPI1 with DMA */
	/* Exchange data with SPI slave using SPI DMA */
	/* Exchange 5 bytes of data */
	TM_SPI_DMA_Transmit(SPI1, TX_Buffer, RX_Buffer, sizeof(TX_Buffer));
	
	/* Wait till SPI DMA do it's job */
	/* You can do other stuff instead */
	while (TM_SPI_DMA_Working(SPI1));
	val = TM_GENERAL_DWTCounterGetValue();
	
	/* Little delay, for debug */
	Delayms(10);
	
	TM_GENERAL_DWTCounterSetValue(0);
	TM_SPI_SendMulti(SPI1, TX_Buffer, RX_Buffer, sizeof(TX_Buffer));
	val = TM_GENERAL_DWTCounterGetValue();
	
	/* Send 5 bytes of data and don't care what you receive back from slave via DMA */
	/* RX_Buffer should not be changed in debug window */
	TM_SPI_DMA_Transmit(SPI1, TX_Buffer, NULL, 5);
	
	/* Wait till SPI DMA do it's job */
	/* You can do other stuff instead */
	while (TM_SPI_DMA_Working(SPI1));
	
	/* Little delay, for debug */
	Delayms(10);
	
	/* Receive 5 bytes of data, sent dummy 0x00 bytes to slave via DMA */
	TM_SPI_DMA_Transmit(SPI1, NULL, RX_Buffer, 5);
	
	/* Wait till SPI DMA do it's job */
	/* You can do other stuff instead */
	while (TM_SPI_DMA_Working(SPI1));
	
	
	/* Set CS high here after last byte is done by SPI */
	
	while (1) {
		
	}
}