Przeglądaj źródła

Use dedicated function to read the status register when transmitting

Bernd Gottschlag 5 lat temu
rodzic
commit
9d1b611356
1 zmienionych plików z 3 dodań i 10 usunięć
  1. 3
    10
      weather-sensor/firmware/nrf24l01.c

+ 3
- 10
weather-sensor/firmware/nrf24l01.c Wyświetl plik

4
 #include <stdio.h>
4
 #include <stdio.h>
5
 #include <stdbool.h>
5
 #include <stdbool.h>
6
 
6
 
7
+#include "spi.h"
7
 #include "nrf24l01.h"
8
 #include "nrf24l01.h"
8
 #include "nrf24l01_definitions.h"
9
 #include "nrf24l01_definitions.h"
9
 #include "uart_debug.h"
10
 #include "uart_debug.h"
112
 	bool transmissionFinished = false;
113
 	bool transmissionFinished = false;
113
 
114
 
114
 	STATUS_REGISTER statusRegisterContents = {.byte = 0x0};
115
 	STATUS_REGISTER statusRegisterContents = {.byte = 0x0};
115
-	uint8_t lengthRead;
116
 	char debugString[50] = "";
116
 	char debugString[50] = "";
117
 	uint32_t timeout = 0;
117
 	uint32_t timeout = 0;
118
-	uint8_t temp = 0;
119
 	/* TODO:
118
 	/* TODO:
120
 	 * - if needed: PRIM_RX = 0
119
 	 * - if needed: PRIM_RX = 0
121
 	 * - Set CE = 1 for more than 10 us
120
 	 * - Set CE = 1 for more than 10 us
137
 	do
136
 	do
138
 	{
137
 	{
139
 		_delay_ms(1);
138
 		_delay_ms(1);
140
-		lengthRead = Read_NRF_Register(STATUS_ADDRESS, &(statusRegisterContents.byte)); /* TODO: use funtion to read status register -> no overflow possible, only one NOP transfer needed, not two */
141
-
142
-		if (lengthRead > 1)
143
-		{
144
-			sprintf(debugString, "%s\r\n", "Read error");
145
-			Print_Debug_String(debugString);
146
-		}
139
+		statusRegisterContents.byte = Read_NRF_Status_Register();
147
 
140
 
148
 		if (statusRegisterContents.bits.TX_DS == 1)
141
 		if (statusRegisterContents.bits.TX_DS == 1)
149
 		{
142
 		{
171
 	}
164
 	}
172
 
165
 
173
 	/* Reset the interrupts */
166
 	/* Reset the interrupts */
174
-	lengthRead = Read_NRF_Register(STATUS_ADDRESS, &(statusRegisterContents.byte)); /* TODO: use status register read function */
167
+	statusRegisterContents.byte = Read_NRF_Status_Register();
175
 	statusRegisterContents.bits.TX_DS = 1;
168
 	statusRegisterContents.bits.TX_DS = 1;
176
 	statusRegisterContents.bits.MAX_RT = 1;
169
 	statusRegisterContents.bits.MAX_RT = 1;
177
 	Write_NRF_Register(STATUS_ADDRESS, statusRegisterContents.byte);
170
 	Write_NRF_Register(STATUS_ADDRESS, statusRegisterContents.byte);

Ładowanie…
Anuluj
Zapisz