LibDriver NRF905
Loading...
Searching...
No Matches
driver_nrf905.c
Go to the documentation of this file.
1
36
37#include "driver_nrf905.h"
38
42#define CHIP_NAME "Nordic nRF905"
43#define MANUFACTURER_NAME "Nordic"
44#define SUPPLY_VOLTAGE_MIN 1.9f
45#define SUPPLY_VOLTAGE_MAX 3.6f
46#define MAX_CURRENT 30.0f
47#define TEMPERATURE_MIN -40.0f
48#define TEMPERATURE_MAX 85.0f
49#define DRIVER_VERSION 1000
50
54#define NRF905_COMMAND_W_CONFIG 0x00
55#define NRF905_COMMAND_R_CONFIG 0x10
56#define NRF905_COMMAND_W_TX_PAYLOAD 0x20
57#define NRF905_COMMAND_R_TX_PAYLOAD 0x21
58#define NRF905_COMMAND_W_TX_ADDRESS 0x22
59#define NRF905_COMMAND_R_TX_ADDRESS 0x23
60#define NRF905_COMMAND_R_RX_PAYLOAD 0x24
61#define NRF905_COMMAND_CHANNEL_CONFIG 0x80
62
66#define NRF905_REG_CH_NO 0x00
67#define NRF905_REG_CONF1 0x01
68#define NRF905_REG_CONF2 0x02
69#define NRF905_REG_RX_PW 0x03
70#define NRF905_REG_TX_PW 0x04
71#define NRF905_REG_RX_ADDRESS_0 0x05
72#define NRF905_REG_RX_ADDRESS_1 0x06
73#define NRF905_REG_RX_ADDRESS_2 0x07
74#define NRF905_REG_RX_ADDRESS_3 0x08
75#define NRF905_REG_CONF3 0x09
76
88static uint8_t a_nrf905_spi_transmit(nrf905_handle_t *handle, uint8_t *tx, uint8_t *rx, uint16_t len)
89{
90 if (handle->spi_transmit(tx, rx, len) != 0) /* spi transmit */
91 {
92 return 1; /* return error */
93 }
94 else
95 {
96 return 0; /* success return 0 */
97 }
98}
99
111static uint8_t a_nrf905_spi_read(nrf905_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
112{
113 if (handle->spi_read(reg, buf, len) != 0) /* spi read */
114 {
115 return 1; /* return error */
116 }
117 else
118 {
119 return 0; /* success return 0 */
120 }
121}
122
134static uint8_t a_nrf905_spi_write(nrf905_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
135{
136 if (handle->spi_write(reg, buf, len) != 0) /* spi write */
137 {
138 return 1; /* return error */
139 }
140 else
141 {
142 return 0; /* success return 0 */
143 }
144}
145
160{
161 if (handle == NULL) /* check handle */
162 {
163 return 2; /* return error */
164 }
165 if (handle->debug_print == NULL) /* check debug_print */
166 {
167 return 3; /* return error */
168 }
169 if (handle->spi_init == NULL) /* check spi_init */
170 {
171 handle->debug_print("nrf905: spi_init is null.\n"); /* spi_init is null */
172
173 return 3; /* return error */
174 }
175 if (handle->spi_deinit == NULL) /* check spi_deinit */
176 {
177 handle->debug_print("nrf905: spi_deinit is null.\n"); /* spi_deinit is null */
178
179 return 3; /* return error */
180 }
181 if (handle->spi_read == NULL) /* check spi_read */
182 {
183 handle->debug_print("nrf905: spi_read is null.\n"); /* spi_read is null */
184
185 return 3; /* return error */
186 }
187 if (handle->spi_write == NULL) /* check spi_write */
188 {
189 handle->debug_print("nrf905: spi_write is null.\n"); /* spi_write is null */
190
191 return 3; /* return error */
192 }
193 if (handle->spi_transmit == NULL) /* check spi_transmit */
194 {
195 handle->debug_print("nrf905: spi_transmit is null.\n"); /* spi_transmit is null */
196
197 return 3; /* return error */
198 }
199 if (handle->ce_gpio_init == NULL) /* check ce_gpio_init */
200 {
201 handle->debug_print("nrf905: ce_gpio_init is null.\n"); /* ce_gpio_init is null */
202
203 return 3; /* return error */
204 }
205 if (handle->ce_gpio_deinit == NULL) /* check ce_gpio_deinit */
206 {
207 handle->debug_print("nrf905: ce_gpio_deinit is null.\n"); /* ce_gpio_deinit is null */
208
209 return 3; /* return error */
210 }
211 if (handle->ce_gpio_write == NULL) /* check ce_gpio_write */
212 {
213 handle->debug_print("nrf905: ce_gpio_write is null.\n"); /* ce_gpio_write is null */
214
215 return 3; /* return error */
216 }
217 if (handle->tx_en_gpio_init == NULL) /* check tx_en_gpio_init */
218 {
219 handle->debug_print("nrf905: tx_en_gpio_init is null.\n"); /* tx_en_gpio_init is null */
220
221 return 3; /* return error */
222 }
223 if (handle->tx_en_gpio_deinit == NULL) /* check tx_en_gpio_deinit */
224 {
225 handle->debug_print("nrf905: tx_en_gpio_deinit is null.\n"); /* tx_en_gpio_deinit is null */
226
227 return 3; /* return error */
228 }
229 if (handle->tx_en_gpio_write == NULL) /* check tx_en_gpio_write */
230 {
231 handle->debug_print("nrf905: tx_en_gpio_write is null.\n"); /* tx_en_gpio_write is null */
232
233 return 3; /* return error */
234 }
235 if (handle->pwr_up_gpio_init == NULL) /* check pwr_up_gpio_init */
236 {
237 handle->debug_print("nrf905: pwr_up_gpio_init is null.\n"); /* pwr_up_gpio_init is null */
238
239 return 3; /* return error */
240 }
241 if (handle->pwr_up_gpio_deinit == NULL) /* check pwr_up_gpio_deinit */
242 {
243 handle->debug_print("nrf905: pwr_up_gpio_deinit is null.\n"); /* pwr_up_gpio_deinit is null */
244
245 return 3; /* return error */
246 }
247 if (handle->pwr_up_gpio_write == NULL) /* check pwr_up_gpio_write */
248 {
249 handle->debug_print("nrf905: pwr_up_gpio_write is null.\n"); /* pwr_up_gpio_write is null */
250
251 return 3; /* return error */
252 }
253 if (handle->delay_ms == NULL) /* check delay_ms */
254 {
255 handle->debug_print("nrf905: delay_ms is null.\n"); /* delay_ms is null */
256
257 return 3; /* return error */
258 }
259 if (handle->receive_callback == NULL) /* check receive_callback */
260 {
261 handle->debug_print("nrf905: receive_callback is null.\n"); /* receive_callback is null */
262
263 return 3; /* return error */
264 }
265
266 if (handle->spi_init() != 0) /* spi init */
267 {
268 handle->debug_print("nrf905: spi init failed.\n"); /* spi init failed */
269
270 return 1; /* return error */
271 }
272 if (handle->pwr_up_gpio_init() != 0) /* pwr up gpio init */
273 {
274 handle->debug_print("nrf905: pwr up gpio init failed.\n"); /* pwr up gpio init failed */
275 (void)handle->spi_deinit(); /* spi deinit */
276
277 return 4; /* return error */
278 }
279 if (handle->ce_gpio_init() != 0) /* ce gpio init */
280 {
281 handle->debug_print("nrf905: ce gpio init failed.\n"); /* ce gpio init failed */
282 (void)handle->spi_deinit(); /* spi deinit */
283 (void)handle->pwr_up_gpio_deinit(); /* pwr up gpio deinit */
284
285 return 5; /* return error */
286 }
287 if (handle->tx_en_gpio_init() != 0) /* tx en gpio init */
288 {
289 handle->debug_print("nrf905: tx en gpio init failed.\n"); /* tx en gpio init failed */
290 (void)handle->spi_deinit(); /* spi deinit */
291 (void)handle->pwr_up_gpio_deinit(); /* pwr up gpio deinit */
292 (void)handle->ce_gpio_deinit(); /* ce gpio deinit */
293
294 return 6; /* return error */
295 }
296 handle->conf[0] = 0x6C; /* set default conf */
297 handle->conf[1] = 0x00; /* set default conf */
298 handle->conf[2] = 0x44; /* set default conf */
299 handle->conf[3] = 0x20; /* set default conf */
300 handle->conf[4] = 0x20; /* set default conf */
301 handle->conf[5] = 0xE7; /* set default conf */
302 handle->conf[6] = 0xE7; /* set default conf */
303 handle->conf[7] = 0xE7; /* set default conf */
304 handle->conf[8] = 0xE7; /* set default conf */
305 handle->conf[9] = 0xE7; /* set default conf */
306
307 handle->inited = 1; /* flag finish initialization */
308
309 return 0; /* success return 0 */
310}
311
327{
328 if (handle == NULL) /* check handle */
329 {
330 return 2; /* return error */
331 }
332 if (handle->inited != 1) /* check handle initialization */
333 {
334 return 3; /* return error */
335 }
336
337 if (handle->pwr_up_gpio_write(0) != 0) /* power down */
338 {
339 handle->debug_print("nrf905: power down failed.\n"); /* power down failed */
340
341 return 1; /* return error */
342 }
343 if (handle->spi_deinit() != 0) /* spi deinit */
344 {
345 handle->debug_print("nrf905: spi deinit failed.\n"); /* spi deinit failed */
346
347 return 4; /* return error */
348 }
349 if (handle->pwr_up_gpio_deinit() != 0) /* pwr up gpio deinit */
350 {
351 handle->debug_print("nrf905: pwr up gpio deinit failed.\n"); /* pwr up gpio deinit failed */
352
353 return 5; /* return error */
354 }
355 if (handle->ce_gpio_deinit() != 0) /* ce gpio deinit */
356 {
357 handle->debug_print("nrf905: ce gpio deinit failed.\n"); /* ce gpio deinit failed */
358
359 return 6; /* return error */
360 }
361 if (handle->tx_en_gpio_deinit() != 0) /* tx en gpio deinit */
362 {
363 handle->debug_print("nrf905: tx en gpio deinit failed.\n"); /* tx en gpio deinit failed */
364
365 return 7; /* return error */
366 }
367
368 handle->inited = 0; /* flag closed */
369
370 return 0; /* success return 0 */
371}
372
384{
385 uint8_t res;
386 uint8_t status;
387 uint8_t reg;
388
389 if (handle == NULL) /* check handle */
390 {
391 return 2; /* return error */
392 }
393 if (handle->inited != 1) /* check handle initialization */
394 {
395 return 3; /* return error */
396 }
397
398 if (handle->ce_gpio_write(0) != 0) /* disable the chip */
399 {
400 handle->debug_print("nrf905: ce gpio write failed.\n"); /* ce gpio write failed */
401
402 return 1; /* return error */
403 }
404 status = 0; /* set 0 */
405 reg = 0xFF; /* set 0xFF */
406 res = a_nrf905_spi_transmit(handle, &reg, (uint8_t *)&status, 1); /* read status */
407 if (res != 0) /* check result */
408 {
409 handle->debug_print("nrf905: get status failed.\n"); /* get status failed */
410 (void)handle->ce_gpio_write(1); /* enable the chip */
411
412 return 1; /* return error */
413 }
414 if ((status & (1 << 5)) != 0) /* if dr */
415 {
416 if (handle->mode == 1) /* if tx mode */
417 {
418 handle->finished = 1; /* flag finished */
419 if (handle->receive_callback != NULL) /* if receive callback */
420 {
421 handle->receive_callback(NRF905_STATUS_TX_DONE, NULL, 0); /* run receive callback */
422 }
423 }
424 else /* if rx mode */
425 {
426 uint8_t buf[32];
427 uint8_t l;
428
429 l = handle->conf[NRF905_REG_RX_PW] > 32 ? 32 : handle->conf[NRF905_REG_RX_PW]; /* get the read length */
430 res = a_nrf905_spi_read(handle, NRF905_COMMAND_R_RX_PAYLOAD, (uint8_t *)buf, l); /* read rx payload */
431 if (res != 0) /* check result */
432 {
433 handle->debug_print("nrf905: get rx payload failed.\n"); /* get rx payload failed */
434 (void)handle->ce_gpio_write(1); /* enable the chip */
435
436 return 1; /* return error */
437 }
438 if (handle->receive_callback != NULL) /* if receive callback */
439 {
440 handle->receive_callback(NRF905_STATUS_RX_DONE, (uint8_t *)buf, l); /* run receive callback */
441 }
442 }
443 }
444 if ((status & (1 << 7)) != 0) /* if am */
445 {
446 if (handle->receive_callback != NULL) /* if receive callback */
447 {
448 handle->receive_callback(NRF905_STATUS_AM, NULL, 0); /* run receive callback */
449 }
450 }
451 if (handle->ce_gpio_write(1) != 0) /* enable the chip */
452 {
453 handle->debug_print("nrf905: ce gpio write failed.\n"); /* ce gpio write failed */
454
455 return 1; /* return error */
456 }
457
458 return 0; /* success return 0 */
459}
460
473{
474 if (handle == NULL) /* check handle */
475 {
476 return 2; /* return error */
477 }
478 if (handle->inited != 1) /* check handle initialization */
479 {
480 return 3; /* return error */
481 }
482
483 if (handle->pwr_up_gpio_write(enable) != 0) /* set power up */
484 {
485 handle->debug_print("nrf905: set power up failed.\n"); /* set power up failed */
486
487 return 1; /* return error */
488 }
489 else
490 {
491 handle->delay_ms(5); /* delay 5ms */
492
493 return 0; /* success return 0 */
494 }
495}
496
509{
510 if (handle == NULL) /* check handle */
511 {
512 return 2; /* return error */
513 }
514 if (handle->inited != 1) /* check handle initialization */
515 {
516 return 3; /* return error */
517 }
518
519 if (handle->ce_gpio_write(enable) != 0) /* set enable */
520 {
521 handle->debug_print("nrf905: set enable failed.\n"); /* set enable failed */
522
523 return 1; /* return error */
524 }
525 else
526 {
527 return 0; /* success return 0 */
528 }
529}
530
543{
544 if (handle == NULL) /* check handle */
545 {
546 return 2; /* return error */
547 }
548 if (handle->inited != 1) /* check handle initialization */
549 {
550 return 3; /* return error */
551 }
552
553 if (handle->tx_en_gpio_write(mode) != 0) /* set mode */
554 {
555 handle->debug_print("nrf905: set mode failed.\n"); /* set enable failed */
556
557 return 1; /* return error */
558 }
559 else
560 {
561 handle->mode = (uint8_t)mode; /* set the chip mode */
562
563 return 0; /* success return 0 */
564 }
565}
566
581uint8_t nrf905_send(nrf905_handle_t *handle, uint8_t *buf, uint8_t len)
582{
583 uint8_t res;
584 uint32_t timeout;
585
586 if (handle == NULL) /* check handle */
587 {
588 return 2; /* return error */
589 }
590 if (handle->inited != 1) /* check handle initialization */
591 {
592 return 3; /* return error */
593 }
594 if (len > handle->conf[NRF905_REG_TX_PW]) /* check the result */
595 {
596 handle->debug_print("nrf905: len is over %d.\n", handle->conf[NRF905_REG_TX_PW]); /* len is over conf */
597
598 return 4; /* return error */
599 }
600
601 if (handle->ce_gpio_write(0) != 0) /* disable the chip */
602 {
603 handle->debug_print("nrf905: ce gpio write failed.\n"); /* ce gpio write failed */
604
605 return 1; /* return error */
606 }
607 if (handle->tx_en_gpio_write(NRF905_MODE_TX) != 0) /* set tx mode */
608 {
609 handle->debug_print("nrf905: tx en gpio write failed.\n"); /* tx en gpio write failed */
610
611 return 1; /* return error */
612 }
613 handle->delay_ms(1); /* wait 1 ms */
614 res = a_nrf905_spi_write(handle, NRF905_COMMAND_W_TX_PAYLOAD, buf, len); /* write tx payload */
615 if (res != 0) /* check result */
616 {
617 handle->debug_print("nrf905: set tx payload failed.\n"); /* set tx payload failed */
618
619 return 1; /* return error */
620 }
621 handle->finished = 0; /* clear finished */
622 handle->mode = NRF905_MODE_TX; /* set the tx mode */
623 if (handle->ce_gpio_write(1) != 0) /* enable the chip */
624 {
625 handle->debug_print("nrf905: ce gpio write failed.\n"); /* ce gpio write failed */
626
627 return 1; /* return error */
628 }
629 timeout = 5000; /* set timeout */
630 while ((timeout != 0) && (handle->finished == 0)) /* wait time */
631 {
632 handle->delay_ms(1); /* delay 1 ms */
633 timeout--; /* timeout-- */
634 }
635 if (handle->ce_gpio_write(0) != 0) /* disable the chip */
636 {
637 handle->debug_print("nrf905: ce gpio write failed.\n"); /* ce gpio write failed */
638
639 return 1; /* return error */
640 }
641 if (timeout == 0) /* check timeout */
642 {
643 handle->debug_print("nrf905: send timeout.\n"); /* send timeout failed */
644
645 return 5; /* return error */
646 }
647 if (handle->finished == 1) /* check finished */
648 {
649 return 0; /* success return 0 */
650 }
651 else
652 {
653 handle->debug_print("nrf905: send failed.\n"); /* send failed */
654
655 return 1; /* return error */
656 }
657}
658
670{
671 uint8_t res;
672
673 if (handle == NULL) /* check handle */
674 {
675 return 2; /* return error */
676 }
677 if (handle->inited != 1) /* check handle initialization */
678 {
679 return 3; /* return error */
680 }
681
682 res = a_nrf905_spi_write(handle, NRF905_COMMAND_W_CONFIG, handle->conf, 10); /* write conf */
683 if (res != 0) /* check result */
684 {
685 handle->debug_print("nrf905: write conf failed.\n"); /* write conf failed */
686
687 return 1; /* return error */
688 }
689
690 return 0; /* success return 0 */
691}
692
704uint8_t nrf905_read_conf(nrf905_handle_t *handle, uint8_t conf[10])
705{
706 uint8_t res;
707
708 if (handle == NULL) /* check handle */
709 {
710 return 2; /* return error */
711 }
712 if (handle->inited != 1) /* check handle initialization */
713 {
714 return 3; /* return error */
715 }
716
717 res = a_nrf905_spi_read(handle, NRF905_COMMAND_R_CONFIG, conf, 10); /* read conf */
718 if (res != 0) /* check result */
719 {
720 handle->debug_print("nrf905: read conf failed.\n"); /* read conf failed */
721
722 return 1; /* return error */
723 }
724
725 return 0; /* success return 0 */
726}
727
739uint8_t nrf905_update_conf(nrf905_handle_t *handle, uint8_t conf[10])
740{
741 if (handle == NULL) /* check handle */
742 {
743 return 2; /* return error */
744 }
745 if (handle->inited != 1) /* check handle initialization */
746 {
747 return 3; /* return error */
748 }
749
750 memcpy(handle->conf, conf, 10); /* copy the conf */
751
752 return 0; /* success return 0 */
753}
754
768uint8_t nrf905_set_tx_payload(nrf905_handle_t *handle, uint8_t *buf, uint8_t len)
769{
770 uint8_t res;
771
772 if (handle == NULL) /* check handle */
773 {
774 return 2; /* return error */
775 }
776 if (handle->inited != 1) /* check handle initialization */
777 {
778 return 3; /* return error */
779 }
780 if (len > 32) /* check the result */
781 {
782 handle->debug_print("nrf905: len is over 32.\n"); /* len is over 32 */
783
784 return 4; /* return error */
785 }
786
787 res = a_nrf905_spi_write(handle, NRF905_COMMAND_W_TX_PAYLOAD, buf, len); /* write tx payload */
788 if (res != 0) /* check result */
789 {
790 handle->debug_print("nrf905: set tx payload failed.\n"); /* set tx payload failed */
791
792 return 1; /* return error */
793 }
794
795 return 0; /* success return 0 */
796}
797
811uint8_t nrf905_get_tx_payload(nrf905_handle_t *handle, uint8_t *buf, uint8_t len)
812{
813 uint8_t res;
814
815 if (handle == NULL) /* check handle */
816 {
817 return 2; /* return error */
818 }
819 if (handle->inited != 1) /* check handle initialization */
820 {
821 return 3; /* return error */
822 }
823 if (len > 32) /* check the result */
824 {
825 handle->debug_print("nrf905: len is over 32.\n"); /* len is over 32 */
826
827 return 4; /* return error */
828 }
829
830 res = a_nrf905_spi_read(handle, NRF905_COMMAND_R_TX_PAYLOAD, buf, len); /* read tx payload */
831 if (res != 0) /* check result */
832 {
833 handle->debug_print("nrf905: get tx payload failed.\n"); /* get tx payload failed */
834
835 return 1; /* return error */
836 }
837
838 return 0; /* success return 0 */
839}
840
854uint8_t nrf905_get_rx_payload(nrf905_handle_t *handle, uint8_t *buf, uint8_t len)
855{
856 uint8_t res;
857
858 if (handle == NULL) /* check handle */
859 {
860 return 2; /* return error */
861 }
862 if (handle->inited != 1) /* check handle initialization */
863 {
864 return 3; /* return error */
865 }
866 if (len > 32) /* check the result */
867 {
868 handle->debug_print("nrf905: len is over 32.\n"); /* len is over 32 */
869
870 return 4; /* return error */
871 }
872
873 res = a_nrf905_spi_read(handle, NRF905_COMMAND_R_RX_PAYLOAD, buf, len); /* read rx payload */
874 if (res != 0) /* check result */
875 {
876 handle->debug_print("nrf905: get rx payload failed.\n"); /* get rx payload failed */
877
878 return 1; /* return error */
879 }
880
881 return 0; /* success return 0 */
882}
883
897uint8_t nrf905_set_tx_address(nrf905_handle_t *handle, uint8_t *addr, uint8_t len)
898{
899 uint8_t res;
900
901 if (handle == NULL) /* check handle */
902 {
903 return 2; /* return error */
904 }
905 if (handle->inited != 1) /* check handle initialization */
906 {
907 return 3; /* return error */
908 }
909 if (len > 4) /* check the result */
910 {
911 handle->debug_print("nrf905: len is over 4.\n"); /* len is over 4 */
912
913 return 4; /* return error */
914 }
915
916 res = a_nrf905_spi_write(handle, NRF905_COMMAND_W_TX_ADDRESS, addr, len); /* write tx address */
917 if (res != 0) /* check result */
918 {
919 handle->debug_print("nrf905: set tx address failed.\n"); /* set tx address failed */
920
921 return 1; /* return error */
922 }
923
924 return 0; /* success return 0 */
925}
926
940uint8_t nrf905_get_tx_address(nrf905_handle_t *handle, uint8_t *addr, uint8_t len)
941{
942 uint8_t res;
943
944 if (handle == NULL) /* check handle */
945 {
946 return 2; /* return error */
947 }
948 if (handle->inited != 1) /* check handle initialization */
949 {
950 return 3; /* return error */
951 }
952 if (len > 4) /* check the result */
953 {
954 handle->debug_print("nrf905: len is over 4.\n"); /* len is over 4 */
955
956 return 4; /* return error */
957 }
958
959 res = a_nrf905_spi_read(handle, NRF905_COMMAND_R_TX_ADDRESS, addr, len); /* read tx address */
960 if (res != 0) /* check result */
961 {
962 handle->debug_print("nrf905: get tx address failed.\n"); /* get tx address failed */
963
964 return 1; /* return error */
965 }
966
967 return 0; /* success return 0 */
968}
969
985{
986 uint8_t res;
987 uint8_t buf[2];
988
989 if (handle == NULL) /* check handle */
990 {
991 return 2; /* return error */
992 }
993 if (handle->inited != 1) /* check handle initialization */
994 {
995 return 3; /* return error */
996 }
997 if (freq > 0x1FF) /* check the result */
998 {
999 handle->debug_print("nrf905: freq is over 0x1FF.\n"); /* freq is over 0x1FF */
1000
1001 return 4; /* return error */
1002 }
1003
1004 buf[0] = (uint8_t)(NRF905_COMMAND_CHANNEL_CONFIG |
1005 power << 2 | mode << 1 | ((freq >> 8) & 0x1)); /* set buf0 */
1006 buf[1] = (uint8_t)(freq & 0xFF); /* set buf1 */
1007 res = a_nrf905_spi_write(handle, buf[0], &buf[1], 1); /* channel config */
1008 if (res != 0) /* check result */
1009 {
1010 handle->debug_print("nrf905: channel config failed.\n"); /* channel config failed */
1011
1012 return 1; /* return error */
1013 }
1014
1015 return 0; /* success return 0 */
1016}
1017
1029uint8_t nrf905_get_status(nrf905_handle_t *handle, uint8_t *status)
1030{
1031 uint8_t res;
1032 uint8_t reg;
1033
1034 if (handle == NULL) /* check handle */
1035 {
1036 return 2; /* return error */
1037 }
1038 if (handle->inited != 1) /* check handle initialization */
1039 {
1040 return 3; /* return error */
1041 }
1042
1043 reg = 0xFF; /* set 0xFF */
1044 res = a_nrf905_spi_transmit(handle, &reg, (uint8_t *)status, 1); /* read status */
1045 if (res != 0) /* check result */
1046 {
1047 handle->debug_print("nrf905: get status failed.\n"); /* get status failed */
1048
1049 return 1; /* return error */
1050 }
1051
1052 return 0; /* success return 0 */
1053}
1054
1067uint8_t nrf905_set_frequency(nrf905_handle_t *handle, uint16_t freq)
1068{
1069 uint8_t prev;
1070
1071 if (handle == NULL) /* check handle */
1072 {
1073 return 2; /* return error */
1074 }
1075 if (handle->inited != 1) /* check handle initialization */
1076 {
1077 return 3; /* return error */
1078 }
1079 if (freq > 0x1FF) /* check the result */
1080 {
1081 handle->debug_print("nrf905: freq is over 0x1FF.\n"); /* freq is over 0x1FF */
1082
1083 return 4; /* return error */
1084 }
1085
1086 handle->conf[NRF905_REG_CH_NO] = freq & 0xFF; /* set the frequency */
1087 prev = handle->conf[NRF905_REG_CONF1]; /* get the conf1 */
1088 prev &= ~(1 << 0); /* clear the frequency */
1089 prev |= (freq >> 8) & 0x01; /* set the frequency */
1090 handle->conf[NRF905_REG_CONF1] = prev; /* set the conf */
1091
1092 return 0; /* success return 0 */
1093}
1094
1106uint8_t nrf905_get_frequency(nrf905_handle_t *handle, uint16_t *freq)
1107{
1108 uint8_t prev;
1109
1110 if (handle == NULL) /* check handle */
1111 {
1112 return 2; /* return error */
1113 }
1114 if (handle->inited != 1) /* check handle initialization */
1115 {
1116 return 3; /* return error */
1117 }
1118
1119 *freq = 0; /* set freq 0 */
1120 prev = handle->conf[NRF905_REG_CH_NO]; /* set the frequency */
1121 *freq |= prev; /* set the freq */
1122 prev = handle->conf[NRF905_REG_CONF1]; /* get the conf1 */
1123 *freq |= ((uint16_t)prev & 0x01) << 8; /* set the frequency */
1124
1125 return 0; /* success return 0 */
1126}
1127
1139uint8_t nrf905_frequency_convert_to_register(nrf905_handle_t *handle, float mhz, uint16_t *reg)
1140{
1141 uint8_t bw;
1142
1143 if (handle == NULL) /* check handle */
1144 {
1145 return 2; /* return error */
1146 }
1147 if (handle->inited != 1) /* check handle initialization */
1148 {
1149 return 3; /* return error */
1150 }
1151
1152 bw = (handle->conf[NRF905_REG_CONF1] >> 1) & 0x01; /* set bw */
1153 *reg = (uint16_t)(((mhz / (1 + bw)) - 422.4f) * 10.0f); /* convert real data to register data */
1154
1155 return 0; /* success return 0 */
1156}
1157
1169uint8_t nrf905_frequency_convert_to_data(nrf905_handle_t *handle, uint16_t reg, float *mhz)
1170{
1171 uint8_t bw;
1172
1173 if (handle == NULL) /* check handle */
1174 {
1175 return 2; /* return error */
1176 }
1177 if (handle->inited != 1) /* check handle initialization */
1178 {
1179 return 3; /* return error */
1180 }
1181
1182 bw = (handle->conf[NRF905_REG_CONF1] >> 1) & 0x01; /* set bw */
1183 *mhz = (float)(422.4f + (float)reg / 10.0f) * (1 + bw); /* convert real data to register data */
1184
1185 return 0; /* success return 0 */
1186}
1187
1200{
1201 uint8_t prev;
1202
1203 if (handle == NULL) /* check handle */
1204 {
1205 return 2; /* return error */
1206 }
1207 if (handle->inited != 1) /* check handle initialization */
1208 {
1209 return 3; /* return error */
1210 }
1211
1212 prev = handle->conf[NRF905_REG_CONF1]; /* get the conf1 */
1213 prev &= ~(1 << 1); /* clear the config */
1214 prev |= mode << 1; /* set the config */
1215 handle->conf[NRF905_REG_CONF1] = prev; /* set the conf */
1216
1217 return 0; /* success return 0 */
1218}
1219
1232{
1233 uint8_t prev;
1234
1235 if (handle == NULL) /* check handle */
1236 {
1237 return 2; /* return error */
1238 }
1239 if (handle->inited != 1) /* check handle initialization */
1240 {
1241 return 3; /* return error */
1242 }
1243
1244 prev = handle->conf[NRF905_REG_CONF1]; /* get the conf1 */
1245 *mode = (nrf905_pll_mode_t)((prev >> 1) & 0x01); /* get the mode */
1246
1247 return 0; /* success return 0 */
1248}
1249
1262{
1263 uint8_t prev;
1264
1265 if (handle == NULL) /* check handle */
1266 {
1267 return 2; /* return error */
1268 }
1269 if (handle->inited != 1) /* check handle initialization */
1270 {
1271 return 3; /* return error */
1272 }
1273
1274 prev = handle->conf[NRF905_REG_CONF1]; /* get the conf1 */
1275 prev &= ~(3 << 2); /* clear the config */
1276 prev |= output_power << 2; /* set the config */
1277 handle->conf[NRF905_REG_CONF1] = prev; /* set the conf */
1278
1279 return 0; /* success return 0 */
1280}
1281
1294{
1295 uint8_t prev;
1296
1297 if (handle == NULL) /* check handle */
1298 {
1299 return 2; /* return error */
1300 }
1301 if (handle->inited != 1) /* check handle initialization */
1302 {
1303 return 3; /* return error */
1304 }
1305
1306 prev = handle->conf[NRF905_REG_CONF1]; /* get the conf1 */
1307 *output_power = (nrf905_output_power_t)((prev >> 2) & 0x03); /* get the output power */
1308
1309 return 0; /* success return 0 */
1310}
1311
1324{
1325 uint8_t prev;
1326
1327 if (handle == NULL) /* check handle */
1328 {
1329 return 2; /* return error */
1330 }
1331 if (handle->inited != 1) /* check handle initialization */
1332 {
1333 return 3; /* return error */
1334 }
1335
1336 prev = handle->conf[NRF905_REG_CONF1]; /* get the conf1 */
1337 prev &= ~(1 << 4); /* clear the config */
1338 prev |= mode << 4; /* set the config */
1339 handle->conf[NRF905_REG_CONF1] = prev; /* set the conf */
1340
1341 return 0; /* success return 0 */
1342}
1343
1356{
1357 uint8_t prev;
1358
1359 if (handle == NULL) /* check handle */
1360 {
1361 return 2; /* return error */
1362 }
1363 if (handle->inited != 1) /* check handle initialization */
1364 {
1365 return 3; /* return error */
1366 }
1367
1368 prev = handle->conf[NRF905_REG_CONF1]; /* get the conf1 */
1369 *mode = (nrf905_rx_mode_t)((prev >> 4) & 0x01); /* get the mode */
1370
1371 return 0; /* success return 0 */
1372}
1373
1386{
1387 uint8_t prev;
1388
1389 if (handle == NULL) /* check handle */
1390 {
1391 return 2; /* return error */
1392 }
1393 if (handle->inited != 1) /* check handle initialization */
1394 {
1395 return 3; /* return error */
1396 }
1397
1398 prev = handle->conf[NRF905_REG_CONF1]; /* get the conf1 */
1399 prev &= ~(1 << 5); /* clear the config */
1400 prev |= enable << 5; /* set the config */
1401 handle->conf[NRF905_REG_CONF1] = prev; /* set the conf */
1402
1403 return 0; /* success return 0 */
1404}
1405
1418{
1419 uint8_t prev;
1420
1421 if (handle == NULL) /* check handle */
1422 {
1423 return 2; /* return error */
1424 }
1425 if (handle->inited != 1) /* check handle initialization */
1426 {
1427 return 3; /* return error */
1428 }
1429
1430 prev = handle->conf[NRF905_REG_CONF1]; /* get the conf1 */
1431 *enable = (nrf905_bool_t)((prev >> 5) & 0x01); /* get enable */
1432
1433 return 0; /* success return 0 */
1434}
1435
1448{
1449 uint8_t prev;
1450
1451 if (handle == NULL) /* check handle */
1452 {
1453 return 2; /* return error */
1454 }
1455 if (handle->inited != 1) /* check handle initialization */
1456 {
1457 return 3; /* return error */
1458 }
1459
1460 prev = handle->conf[NRF905_REG_CONF2]; /* get the conf2 */
1461 prev &= ~(7 << 0); /* clear the config */
1462 prev |= width << 0; /* set the config */
1463 handle->conf[NRF905_REG_CONF2] = prev; /* set the conf */
1464
1465 return 0; /* success return 0 */
1466}
1467
1480{
1481 uint8_t prev;
1482
1483 if (handle == NULL) /* check handle */
1484 {
1485 return 2; /* return error */
1486 }
1487 if (handle->inited != 1) /* check handle initialization */
1488 {
1489 return 3; /* return error */
1490 }
1491
1492 prev = handle->conf[NRF905_REG_CONF2]; /* get the conf2 */
1493 *width = (nrf905_address_width_t)((prev >> 0) & 0x07); /* get the address width */
1494
1495 return 0; /* success return 0 */
1496}
1497
1510{
1511 uint8_t prev;
1512
1513 if (handle == NULL) /* check handle */
1514 {
1515 return 2; /* return error */
1516 }
1517 if (handle->inited != 1) /* check handle initialization */
1518 {
1519 return 3; /* return error */
1520 }
1521
1522 prev = handle->conf[NRF905_REG_CONF2]; /* get the conf2 */
1523 prev &= ~(7 << 4); /* clear the config */
1524 prev |= width << 4; /* set the config */
1525 handle->conf[NRF905_REG_CONF2] = prev; /* set the conf */
1526
1527 return 0; /* success return 0 */
1528}
1529
1542{
1543 uint8_t prev;
1544
1545 if (handle == NULL) /* check handle */
1546 {
1547 return 2; /* return error */
1548 }
1549 if (handle->inited != 1) /* check handle initialization */
1550 {
1551 return 3; /* return error */
1552 }
1553
1554 prev = handle->conf[NRF905_REG_CONF2]; /* get the conf2 */
1555 *width = (nrf905_address_width_t)((prev >> 4) & 0x07); /* get the address width */
1556
1557 return 0; /* success return 0 */
1558}
1559
1572uint8_t nrf905_set_rx_payload_width(nrf905_handle_t *handle, uint8_t width)
1573{
1574 if (handle == NULL) /* check handle */
1575 {
1576 return 2; /* return error */
1577 }
1578 if (handle->inited != 1) /* check handle initialization */
1579 {
1580 return 3; /* return error */
1581 }
1582 if (width > 0x20) /* check the result */
1583 {
1584 handle->debug_print("nrf905: width is over 0x20.\n"); /* width is over 0x20 */
1585
1586 return 4; /* return error */
1587 }
1588
1589 handle->conf[NRF905_REG_RX_PW] = width; /* set the rx pw */
1590
1591 return 0; /* success return 0 */
1592}
1593
1605uint8_t nrf905_get_rx_payload_width(nrf905_handle_t *handle, uint8_t *width)
1606{
1607 if (handle == NULL) /* check handle */
1608 {
1609 return 2; /* return error */
1610 }
1611 if (handle->inited != 1) /* check handle initialization */
1612 {
1613 return 3; /* return error */
1614 }
1615
1616 *width = handle->conf[NRF905_REG_RX_PW]; /* get the rx pw */
1617
1618 return 0; /* success return 0 */
1619}
1620
1633uint8_t nrf905_set_tx_payload_width(nrf905_handle_t *handle, uint8_t width)
1634{
1635 if (handle == NULL) /* check handle */
1636 {
1637 return 2; /* return error */
1638 }
1639 if (handle->inited != 1) /* check handle initialization */
1640 {
1641 return 3; /* return error */
1642 }
1643 if (width > 0x20) /* check the result */
1644 {
1645 handle->debug_print("nrf905: width is over 0x20.\n"); /* width is over 0x20 */
1646
1647 return 4; /* return error */
1648 }
1649
1650 handle->conf[NRF905_REG_TX_PW] = width; /* set the tx pw */
1651
1652 return 0; /* success return 0 */
1653}
1654
1666uint8_t nrf905_get_tx_payload_width(nrf905_handle_t *handle, uint8_t *width)
1667{
1668 if (handle == NULL) /* check handle */
1669 {
1670 return 2; /* return error */
1671 }
1672 if (handle->inited != 1) /* check handle initialization */
1673 {
1674 return 3; /* return error */
1675 }
1676
1677 *width = handle->conf[NRF905_REG_TX_PW]; /* get the tx pw */
1678
1679 return 0; /* success return 0 */
1680}
1681
1693uint8_t nrf905_set_rx_address(nrf905_handle_t *handle, uint8_t addr[4])
1694{
1695 if (handle == NULL) /* check handle */
1696 {
1697 return 2; /* return error */
1698 }
1699 if (handle->inited != 1) /* check handle initialization */
1700 {
1701 return 3; /* return error */
1702 }
1703
1704 memcpy(&handle->conf[NRF905_REG_RX_ADDRESS_0], addr, 4); /* copy the rx address */
1705
1706 return 0; /* success return 0 */
1707}
1708
1720uint8_t nrf905_get_rx_address(nrf905_handle_t *handle, uint8_t addr[4])
1721{
1722 if (handle == NULL) /* check handle */
1723 {
1724 return 2; /* return error */
1725 }
1726 if (handle->inited != 1) /* check handle initialization */
1727 {
1728 return 3; /* return error */
1729 }
1730
1731 memcpy(addr, &handle->conf[NRF905_REG_RX_ADDRESS_0], 4); /* copy the rx address */
1732
1733 return 0; /* success return 0 */
1734}
1735
1748{
1749 uint8_t prev;
1750
1751 if (handle == NULL) /* check handle */
1752 {
1753 return 2; /* return error */
1754 }
1755 if (handle->inited != 1) /* check handle initialization */
1756 {
1757 return 3; /* return error */
1758 }
1759
1760 prev = handle->conf[NRF905_REG_CONF3]; /* get the conf3 */
1761 prev &= ~(3 << 0); /* clear the config */
1762 prev |= freq << 0; /* set the config */
1763 handle->conf[NRF905_REG_CONF3] = prev; /* set the conf */
1764
1765 return 0; /* success return 0 */
1766}
1767
1780{
1781 uint8_t prev;
1782
1783 if (handle == NULL) /* check handle */
1784 {
1785 return 2; /* return error */
1786 }
1787 if (handle->inited != 1) /* check handle initialization */
1788 {
1789 return 3; /* return error */
1790 }
1791
1792 prev = handle->conf[NRF905_REG_CONF3]; /* get the conf3 */
1793 *freq = (nrf905_output_clock_frequency_t)((prev >> 0) & 0x3); /* get the freq */
1794
1795 return 0; /* success return 0 */
1796}
1797
1810{
1811 uint8_t prev;
1812
1813 if (handle == NULL) /* check handle */
1814 {
1815 return 2; /* return error */
1816 }
1817 if (handle->inited != 1) /* check handle initialization */
1818 {
1819 return 3; /* return error */
1820 }
1821
1822 prev = handle->conf[NRF905_REG_CONF3]; /* get the conf3 */
1823 prev &= ~(1 << 2); /* clear the config */
1824 prev |= enable << 2; /* set the config */
1825 handle->conf[NRF905_REG_CONF3] = prev; /* set the conf */
1826
1827 return 0; /* success return 0 */
1828}
1829
1842{
1843 uint8_t prev;
1844
1845 if (handle == NULL) /* check handle */
1846 {
1847 return 2; /* return error */
1848 }
1849 if (handle->inited != 1) /* check handle initialization */
1850 {
1851 return 3; /* return error */
1852 }
1853
1854 prev = handle->conf[NRF905_REG_CONF3]; /* get the conf3 */
1855 *enable = (nrf905_bool_t)((prev >> 2) & 0x1); /* get the bool value */
1856
1857 return 0; /* success return 0 */
1858}
1859
1872{
1873 uint8_t prev;
1874
1875 if (handle == NULL) /* check handle */
1876 {
1877 return 2; /* return error */
1878 }
1879 if (handle->inited != 1) /* check handle initialization */
1880 {
1881 return 3; /* return error */
1882 }
1883
1884 prev = handle->conf[NRF905_REG_CONF3]; /* get the conf3 */
1885 prev &= ~(7 << 3); /* clear the config */
1886 prev |= freq << 3; /* set the config */
1887 handle->conf[NRF905_REG_CONF3] = prev; /* set the conf */
1888
1889 return 0; /* success return 0 */
1890}
1891
1904{
1905 uint8_t prev;
1906
1907 if (handle == NULL) /* check handle */
1908 {
1909 return 2; /* return error */
1910 }
1911 if (handle->inited != 1) /* check handle initialization */
1912 {
1913 return 3; /* return error */
1914 }
1915
1916 prev = handle->conf[NRF905_REG_CONF3]; /* get the conf3 */
1917 *freq = (nrf905_crystal_oscillator_frequency_t)((prev >> 3) & 0x7); /* get the frequency */
1918
1919 return 0; /* success return 0 */
1920}
1921
1934{
1935 uint8_t prev;
1936
1937 if (handle == NULL) /* check handle */
1938 {
1939 return 2; /* return error */
1940 }
1941 if (handle->inited != 1) /* check handle initialization */
1942 {
1943 return 3; /* return error */
1944 }
1945
1946 prev = handle->conf[NRF905_REG_CONF3]; /* get the conf3 */
1947 prev &= ~(1 << 6); /* clear the config */
1948 prev |= enable << 6; /* set the config */
1949 handle->conf[NRF905_REG_CONF3] = prev; /* set the conf */
1950
1951 return 0; /* success return 0 */
1952}
1953
1966{
1967 uint8_t prev;
1968
1969 if (handle == NULL) /* check handle */
1970 {
1971 return 2; /* return error */
1972 }
1973 if (handle->inited != 1) /* check handle initialization */
1974 {
1975 return 3; /* return error */
1976 }
1977
1978 prev = handle->conf[NRF905_REG_CONF3]; /* get the conf3 */
1979 *enable = (nrf905_bool_t)((prev >> 6) & 0x1); /* get the bool value */
1980
1981 return 0; /* success return 0 */
1982}
1983
1996{
1997 uint8_t prev;
1998
1999 if (handle == NULL) /* check handle */
2000 {
2001 return 2; /* return error */
2002 }
2003 if (handle->inited != 1) /* check handle initialization */
2004 {
2005 return 3; /* return error */
2006 }
2007
2008 prev = handle->conf[NRF905_REG_CONF3]; /* get the conf3 */
2009 prev &= ~(1 << 7); /* clear the config */
2010 prev |= mode << 7; /* set the config */
2011 handle->conf[NRF905_REG_CONF3] = prev; /* set the conf */
2012
2013 return 0; /* success return 0 */
2014}
2015
2028{
2029 uint8_t prev;
2030
2031 if (handle == NULL) /* check handle */
2032 {
2033 return 2; /* return error */
2034 }
2035 if (handle->inited != 1) /* check handle initialization */
2036 {
2037 return 3; /* return error */
2038 }
2039
2040 prev = handle->conf[NRF905_REG_CONF3]; /* get the conf3 */
2041 *mode = (nrf905_crc_mode_t)((prev >> 7) & 0x1); /* get the mode */
2042
2043 return 0; /* success return 0 */
2044}
2045
2059uint8_t nrf905_set_reg(nrf905_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
2060{
2061 if (handle == NULL) /* check handle */
2062 {
2063 return 2; /* return error */
2064 }
2065 if (handle->inited != 1) /* check handle initialization */
2066 {
2067 return 3; /* return error */
2068 }
2069
2070 return a_nrf905_spi_write(handle, reg, buf, len); /* write data */
2071}
2072
2086uint8_t nrf905_get_reg(nrf905_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
2087{
2088 if (handle == NULL) /* check handle */
2089 {
2090 return 2; /* return error */
2091 }
2092 if (handle->inited != 1) /* check handle initialization */
2093 {
2094 return 3; /* return error */
2095 }
2096
2097 return a_nrf905_spi_read(handle, reg, buf, len); /* read data */
2098}
2099
2109{
2110 if (info == NULL) /* check handle */
2111 {
2112 return 2; /* return error */
2113 }
2114
2115 memset(info, 0, sizeof(nrf905_info_t)); /* initialize nrf905 info structure */
2116 strncpy(info->chip_name, CHIP_NAME, 32); /* copy chip name */
2117 strncpy(info->manufacturer_name, MANUFACTURER_NAME, 32); /* copy manufacturer name */
2118 strncpy(info->interface, "SPI", 8); /* copy interface name */
2119 info->supply_voltage_min_v = SUPPLY_VOLTAGE_MIN; /* set minimal supply voltage */
2120 info->supply_voltage_max_v = SUPPLY_VOLTAGE_MAX; /* set maximum supply voltage */
2121 info->max_current_ma = MAX_CURRENT; /* set maximum current */
2122 info->temperature_max = TEMPERATURE_MAX; /* set minimal temperature */
2123 info->temperature_min = TEMPERATURE_MIN; /* set maximum temperature */
2124 info->driver_version = DRIVER_VERSION; /* set driver version */
2125
2126 return 0; /* success return 0 */
2127}
#define NRF905_REG_CONF1
#define MAX_CURRENT
#define NRF905_REG_CONF3
#define NRF905_REG_RX_PW
#define NRF905_COMMAND_R_TX_ADDRESS
#define NRF905_COMMAND_W_TX_ADDRESS
#define SUPPLY_VOLTAGE_MAX
#define NRF905_COMMAND_R_RX_PAYLOAD
#define NRF905_REG_RX_ADDRESS_0
#define NRF905_REG_TX_PW
#define NRF905_REG_CONF2
#define TEMPERATURE_MAX
#define NRF905_COMMAND_W_CONFIG
chip command definition
#define MANUFACTURER_NAME
#define TEMPERATURE_MIN
#define SUPPLY_VOLTAGE_MIN
#define NRF905_COMMAND_W_TX_PAYLOAD
#define NRF905_REG_CH_NO
chip byte definition
#define NRF905_COMMAND_R_TX_PAYLOAD
#define CHIP_NAME
chip information definition
#define DRIVER_VERSION
#define NRF905_COMMAND_CHANNEL_CONFIG
#define NRF905_COMMAND_R_CONFIG
driver nrf905 header file
nrf905_address_width_t
nrf905 address width enumeration definition
uint8_t nrf905_set_output_clock(nrf905_handle_t *handle, nrf905_bool_t enable)
enable or disable the output clock
nrf905_output_clock_frequency_t
nrf905 output clock frequency enumeration definition
uint8_t nrf905_get_rx_address_width(nrf905_handle_t *handle, nrf905_address_width_t *width)
get the rx address width
uint8_t nrf905_set_frequency(nrf905_handle_t *handle, uint16_t freq)
set the frequency
uint8_t nrf905_read_conf(nrf905_handle_t *handle, uint8_t conf[10])
read the conf
uint8_t nrf905_set_tx_payload_width(nrf905_handle_t *handle, uint8_t width)
set the tx payload width
uint8_t nrf905_init(nrf905_handle_t *handle)
initialize the chip
uint8_t nrf905_get_crc_mode(nrf905_handle_t *handle, nrf905_crc_mode_t *mode)
get the crc mode
uint8_t nrf905_get_auto_retransmit(nrf905_handle_t *handle, nrf905_bool_t *enable)
get the auto retransmit status
nrf905_crystal_oscillator_frequency_t
nrf905 crystal oscillator frequency enumeration definition
uint8_t nrf905_update_conf(nrf905_handle_t *handle, uint8_t conf[10])
update the conf
uint8_t nrf905_get_rx_address(nrf905_handle_t *handle, uint8_t addr[4])
get the rx address
uint8_t nrf905_frequency_convert_to_register(nrf905_handle_t *handle, float mhz, uint16_t *reg)
convert the frequency to the register raw data
nrf905_crc_mode_t
nrf905 crc mode enumeration definition
uint8_t nrf905_set_crc_mode(nrf905_handle_t *handle, nrf905_crc_mode_t mode)
set the crc mode
uint8_t nrf905_set_pll_mode(nrf905_handle_t *handle, nrf905_pll_mode_t mode)
set the pll mode
nrf905_output_power_t
nrf905 output power enumeration definition
nrf905_mode_t
nrf905 mode enumeration definition
uint8_t nrf905_get_tx_payload_width(nrf905_handle_t *handle, uint8_t *width)
get the tx payload width
uint8_t nrf905_set_output_power(nrf905_handle_t *handle, nrf905_output_power_t output_power)
set the output power
uint8_t nrf905_set_enable(nrf905_handle_t *handle, nrf905_bool_t enable)
enable or disable the chip
struct nrf905_info_s nrf905_info_t
nrf905 information structure definition
nrf905_pll_mode_t
nrf905 pll mode enumeration definition
uint8_t nrf905_get_tx_address_width(nrf905_handle_t *handle, nrf905_address_width_t *width)
get the tx address width
uint8_t nrf905_get_tx_payload(nrf905_handle_t *handle, uint8_t *buf, uint8_t len)
get the tx payload
uint8_t nrf905_set_rx_payload_width(nrf905_handle_t *handle, uint8_t width)
set the rx payload width
uint8_t nrf905_set_power_up(nrf905_handle_t *handle, nrf905_bool_t enable)
set the power up
uint8_t nrf905_get_status(nrf905_handle_t *handle, uint8_t *status)
get the status
uint8_t nrf905_get_rx_mode(nrf905_handle_t *handle, nrf905_rx_mode_t *mode)
get the rx mode
uint8_t nrf905_get_output_power(nrf905_handle_t *handle, nrf905_output_power_t *output_power)
get the output power
uint8_t nrf905_set_rx_address_width(nrf905_handle_t *handle, nrf905_address_width_t width)
set the rx address width
uint8_t nrf905_send(nrf905_handle_t *handle, uint8_t *buf, uint8_t len)
send data
uint8_t nrf905_set_crystal_oscillator_frequency(nrf905_handle_t *handle, nrf905_crystal_oscillator_frequency_t freq)
set the crystal oscillator frequency
uint8_t nrf905_set_rx_address(nrf905_handle_t *handle, uint8_t addr[4])
set the rx address
uint8_t nrf905_info(nrf905_info_t *info)
get chip's information
uint8_t nrf905_set_tx_address_width(nrf905_handle_t *handle, nrf905_address_width_t width)
set the tx address width
uint8_t nrf905_get_output_clock(nrf905_handle_t *handle, nrf905_bool_t *enable)
get the output clock status
uint8_t nrf905_set_tx_address(nrf905_handle_t *handle, uint8_t *addr, uint8_t len)
set the tx address
uint8_t nrf905_get_pll_mode(nrf905_handle_t *handle, nrf905_pll_mode_t *mode)
get the pll mode
uint8_t nrf905_set_rx_mode(nrf905_handle_t *handle, nrf905_rx_mode_t mode)
set the rx mode
uint8_t nrf905_write_conf(nrf905_handle_t *handle)
write the conf
uint8_t nrf905_frequency_convert_to_data(nrf905_handle_t *handle, uint16_t reg, float *mhz)
convert the register raw data to the frequency
uint8_t nrf905_irq_handler(nrf905_handle_t *handle)
irq handler
uint8_t nrf905_get_tx_address(nrf905_handle_t *handle, uint8_t *addr, uint8_t len)
get the tx address
uint8_t nrf905_get_crystal_oscillator_frequency(nrf905_handle_t *handle, nrf905_crystal_oscillator_frequency_t *freq)
get the crystal oscillator frequency
uint8_t nrf905_set_auto_retransmit(nrf905_handle_t *handle, nrf905_bool_t enable)
enable or disable the auto retransmit
uint8_t nrf905_get_rx_payload_width(nrf905_handle_t *handle, uint8_t *width)
get the rx payload width
uint8_t nrf905_set_output_clock_frequency(nrf905_handle_t *handle, nrf905_output_clock_frequency_t freq)
set the output clock frequency
uint8_t nrf905_set_mode(nrf905_handle_t *handle, nrf905_mode_t mode)
set the mode
uint8_t nrf905_channel_config(nrf905_handle_t *handle, uint16_t freq, nrf905_pll_mode_t mode, nrf905_output_power_t power)
config the channel
nrf905_rx_mode_t
nrf905 rx mode enumeration definition
uint8_t nrf905_get_frequency(nrf905_handle_t *handle, uint16_t *freq)
get the frequency
struct nrf905_handle_s nrf905_handle_t
nrf905 handle structure definition
uint8_t nrf905_get_rx_payload(nrf905_handle_t *handle, uint8_t *buf, uint8_t len)
get the rx payload
uint8_t nrf905_set_crc(nrf905_handle_t *handle, nrf905_bool_t enable)
enable or disable the crc
uint8_t nrf905_deinit(nrf905_handle_t *handle)
close the chip
uint8_t nrf905_get_output_clock_frequency(nrf905_handle_t *handle, nrf905_output_clock_frequency_t *freq)
get the output clock frequency
uint8_t nrf905_set_tx_payload(nrf905_handle_t *handle, uint8_t *buf, uint8_t len)
set the tx payload
nrf905_bool_t
nrf905 bool enumeration definition
uint8_t nrf905_get_crc(nrf905_handle_t *handle, nrf905_bool_t *enable)
get the crc status
@ NRF905_MODE_TX
@ NRF905_STATUS_AM
@ NRF905_STATUS_RX_DONE
@ NRF905_STATUS_TX_DONE
uint8_t nrf905_get_reg(nrf905_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
uint8_t nrf905_set_reg(nrf905_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
uint8_t(* ce_gpio_deinit)(void)
uint8_t(* spi_init)(void)
void(* delay_ms)(uint32_t ms)
uint8_t(* spi_read)(uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* spi_write)(uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* tx_en_gpio_init)(void)
void(* receive_callback)(uint8_t type, uint8_t *buf, uint8_t len)
uint8_t(* tx_en_gpio_deinit)(void)
uint8_t(* pwr_up_gpio_deinit)(void)
void(* debug_print)(const char *const fmt,...)
uint8_t(* spi_transmit)(uint8_t *tx, uint8_t *rx, uint16_t len)
uint8_t(* spi_deinit)(void)
uint8_t(* tx_en_gpio_write)(uint8_t value)
uint8_t conf[10]
uint8_t(* pwr_up_gpio_init)(void)
uint8_t(* pwr_up_gpio_write)(uint8_t value)
uint8_t(* ce_gpio_init)(void)
uint8_t(* ce_gpio_write)(uint8_t value)
float supply_voltage_max_v
uint32_t driver_version
char manufacturer_name[32]
float supply_voltage_min_v
char chip_name[32]