Pārlūkot izejas kodu

Use dedicated function to read the status register when transmitting

Bernd Gottschlag 5 gadus atpakaļ
vecāks
revīzija
9d1b611356
1 mainītis faili ar 3 papildinājumiem un 10 dzēšanām
  1. 3
    10
      weather-sensor/firmware/nrf24l01.c

+ 3
- 10
weather-sensor/firmware/nrf24l01.c Parādīt failu

@@ -4,6 +4,7 @@
4 4
 #include <stdio.h>
5 5
 #include <stdbool.h>
6 6
 
7
+#include "spi.h"
7 8
 #include "nrf24l01.h"
8 9
 #include "nrf24l01_definitions.h"
9 10
 #include "uart_debug.h"
@@ -112,10 +113,8 @@ void Send_Test_Message(void)
112 113
 	bool transmissionFinished = false;
113 114
 
114 115
 	STATUS_REGISTER statusRegisterContents = {.byte = 0x0};
115
-	uint8_t lengthRead;
116 116
 	char debugString[50] = "";
117 117
 	uint32_t timeout = 0;
118
-	uint8_t temp = 0;
119 118
 	/* TODO:
120 119
 	 * - if needed: PRIM_RX = 0
121 120
 	 * - Set CE = 1 for more than 10 us
@@ -137,13 +136,7 @@ void Send_Test_Message(void)
137 136
 	do
138 137
 	{
139 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 141
 		if (statusRegisterContents.bits.TX_DS == 1)
149 142
 		{
@@ -171,7 +164,7 @@ void Send_Test_Message(void)
171 164
 	}
172 165
 
173 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 168
 	statusRegisterContents.bits.TX_DS = 1;
176 169
 	statusRegisterContents.bits.MAX_RT = 1;
177 170
 	Write_NRF_Register(STATUS_ADDRESS, statusRegisterContents.byte);

Notiek ielāde…
Atcelt
Saglabāt