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 return 0; /* success return 0 */
492 }
493}
494
507{
508 if (handle == NULL) /* check handle */
509 {
510 return 2; /* return error */
511 }
512 if (handle->inited != 1) /* check handle initialization */
513 {
514 return 3; /* return error */
515 }
516
517 if (handle->ce_gpio_write(enable) != 0) /* set enable */
518 {
519 handle->debug_print("nrf905: set enable failed.\n"); /* set enable failed */
520
521 return 1; /* return error */
522 }
523 else
524 {
525 return 0; /* success return 0 */
526 }
527}
528
541{
542 if (handle == NULL) /* check handle */
543 {
544 return 2; /* return error */
545 }
546 if (handle->inited != 1) /* check handle initialization */
547 {
548 return 3; /* return error */
549 }
550
551 if (handle->tx_en_gpio_write(mode) != 0) /* set mode */
552 {
553 handle->debug_print("nrf905: set mode failed.\n"); /* set enable failed */
554
555 return 1; /* return error */
556 }
557 else
558 {
559 handle->mode = (uint8_t)mode; /* set the chip mode */
560
561 return 0; /* success return 0 */
562 }
563}
564
579uint8_t nrf905_send(nrf905_handle_t *handle, uint8_t *buf, uint8_t len)
580{
581 uint8_t res;
582 uint32_t timeout;
583
584 if (handle == NULL) /* check handle */
585 {
586 return 2; /* return error */
587 }
588 if (handle->inited != 1) /* check handle initialization */
589 {
590 return 3; /* return error */
591 }
592 if (len > handle->conf[NRF905_REG_TX_PW]) /* check the result */
593 {
594 handle->debug_print("nrf905: len is over %d.\n", handle->conf[NRF905_REG_TX_PW]); /* len is over conf */
595
596 return 4; /* return error */
597 }
598
599 if (handle->ce_gpio_write(0) != 0) /* disable the chip */
600 {
601 handle->debug_print("nrf905: ce gpio write failed.\n"); /* ce gpio write failed */
602
603 return 1; /* return error */
604 }
605 if (handle->tx_en_gpio_write(NRF905_MODE_TX) != 0) /* set tx mode */
606 {
607 handle->debug_print("nrf905: tx en gpio write failed.\n"); /* tx en gpio write failed */
608
609 return 1; /* return error */
610 }
611 handle->delay_ms(1); /* wait 1 ms */
612 res = a_nrf905_spi_write(handle, NRF905_COMMAND_W_TX_PAYLOAD, buf, len); /* write tx payload */
613 if (res != 0) /* check result */
614 {
615 handle->debug_print("nrf905: set tx payload failed.\n"); /* set tx payload failed */
616
617 return 1; /* return error */
618 }
619 handle->finished = 0; /* clear finished */
620 handle->mode = NRF905_MODE_TX; /* set the tx mode */
621 if (handle->ce_gpio_write(1) != 0) /* enable the chip */
622 {
623 handle->debug_print("nrf905: ce gpio write failed.\n"); /* ce gpio write failed */
624
625 return 1; /* return error */
626 }
627 timeout = 5000; /* set timeout */
628 while ((timeout != 0) && (handle->finished == 0)) /* wait time */
629 {
630 handle->delay_ms(1); /* delay 1 ms */
631 timeout--; /* timeout-- */
632 }
633 if (handle->ce_gpio_write(0) != 0) /* disable the chip */
634 {
635 handle->debug_print("nrf905: ce gpio write failed.\n"); /* ce gpio write failed */
636
637 return 1; /* return error */
638 }
639 if (timeout == 0) /* check timeout */
640 {
641 handle->debug_print("nrf905: send timeout.\n"); /* send timeout failed */
642
643 return 5; /* return error */
644 }
645 if (handle->finished == 1) /* check finished */
646 {
647 return 0; /* success return 0 */
648 }
649 else
650 {
651 handle->debug_print("nrf905: send failed.\n"); /* send failed */
652
653 return 1; /* return error */
654 }
655}
656
668{
669 uint8_t res;
670
671 if (handle == NULL) /* check handle */
672 {
673 return 2; /* return error */
674 }
675 if (handle->inited != 1) /* check handle initialization */
676 {
677 return 3; /* return error */
678 }
679
680 res = a_nrf905_spi_write(handle, NRF905_COMMAND_W_CONFIG, handle->conf, 10); /* write conf */
681 if (res != 0) /* check result */
682 {
683 handle->debug_print("nrf905: write conf failed.\n"); /* write conf failed */
684
685 return 1; /* return error */
686 }
687
688 return 0; /* success return 0 */
689}
690
702uint8_t nrf905_read_conf(nrf905_handle_t *handle, uint8_t conf[10])
703{
704 uint8_t res;
705
706 if (handle == NULL) /* check handle */
707 {
708 return 2; /* return error */
709 }
710 if (handle->inited != 1) /* check handle initialization */
711 {
712 return 3; /* return error */
713 }
714
715 res = a_nrf905_spi_read(handle, NRF905_COMMAND_R_CONFIG, conf, 10); /* read conf */
716 if (res != 0) /* check result */
717 {
718 handle->debug_print("nrf905: read conf failed.\n"); /* read conf failed */
719
720 return 1; /* return error */
721 }
722
723 return 0; /* success return 0 */
724}
725
737uint8_t nrf905_update_conf(nrf905_handle_t *handle, uint8_t conf[10])
738{
739 if (handle == NULL) /* check handle */
740 {
741 return 2; /* return error */
742 }
743 if (handle->inited != 1) /* check handle initialization */
744 {
745 return 3; /* return error */
746 }
747
748 memcpy(handle->conf, conf, 10); /* copy the conf */
749
750 return 0; /* success return 0 */
751}
752
766uint8_t nrf905_set_tx_payload(nrf905_handle_t *handle, uint8_t *buf, uint8_t len)
767{
768 uint8_t res;
769
770 if (handle == NULL) /* check handle */
771 {
772 return 2; /* return error */
773 }
774 if (handle->inited != 1) /* check handle initialization */
775 {
776 return 3; /* return error */
777 }
778 if (len > 32) /* check the result */
779 {
780 handle->debug_print("nrf905: len is over 32.\n"); /* len is over 32 */
781
782 return 4; /* return error */
783 }
784
785 res = a_nrf905_spi_write(handle, NRF905_COMMAND_W_TX_PAYLOAD, buf, len); /* write tx payload */
786 if (res != 0) /* check result */
787 {
788 handle->debug_print("nrf905: set tx payload failed.\n"); /* set tx payload failed */
789
790 return 1; /* return error */
791 }
792
793 return 0; /* success return 0 */
794}
795
809uint8_t nrf905_get_tx_payload(nrf905_handle_t *handle, uint8_t *buf, uint8_t len)
810{
811 uint8_t res;
812
813 if (handle == NULL) /* check handle */
814 {
815 return 2; /* return error */
816 }
817 if (handle->inited != 1) /* check handle initialization */
818 {
819 return 3; /* return error */
820 }
821 if (len > 32) /* check the result */
822 {
823 handle->debug_print("nrf905: len is over 32.\n"); /* len is over 32 */
824
825 return 4; /* return error */
826 }
827
828 res = a_nrf905_spi_read(handle, NRF905_COMMAND_R_TX_PAYLOAD, buf, len); /* read tx payload */
829 if (res != 0) /* check result */
830 {
831 handle->debug_print("nrf905: get tx payload failed.\n"); /* get tx payload failed */
832
833 return 1; /* return error */
834 }
835
836 return 0; /* success return 0 */
837}
838
852uint8_t nrf905_get_rx_payload(nrf905_handle_t *handle, uint8_t *buf, uint8_t len)
853{
854 uint8_t res;
855
856 if (handle == NULL) /* check handle */
857 {
858 return 2; /* return error */
859 }
860 if (handle->inited != 1) /* check handle initialization */
861 {
862 return 3; /* return error */
863 }
864 if (len > 32) /* check the result */
865 {
866 handle->debug_print("nrf905: len is over 32.\n"); /* len is over 32 */
867
868 return 4; /* return error */
869 }
870
871 res = a_nrf905_spi_read(handle, NRF905_COMMAND_R_RX_PAYLOAD, buf, len); /* read rx payload */
872 if (res != 0) /* check result */
873 {
874 handle->debug_print("nrf905: get rx payload failed.\n"); /* get rx payload failed */
875
876 return 1; /* return error */
877 }
878
879 return 0; /* success return 0 */
880}
881
895uint8_t nrf905_set_tx_address(nrf905_handle_t *handle, uint8_t *addr, uint8_t len)
896{
897 uint8_t res;
898
899 if (handle == NULL) /* check handle */
900 {
901 return 2; /* return error */
902 }
903 if (handle->inited != 1) /* check handle initialization */
904 {
905 return 3; /* return error */
906 }
907 if (len > 4) /* check the result */
908 {
909 handle->debug_print("nrf905: len is over 4.\n"); /* len is over 4 */
910
911 return 4; /* return error */
912 }
913
914 res = a_nrf905_spi_write(handle, NRF905_COMMAND_W_TX_ADDRESS, addr, len); /* write tx address */
915 if (res != 0) /* check result */
916 {
917 handle->debug_print("nrf905: set tx address failed.\n"); /* set tx address failed */
918
919 return 1; /* return error */
920 }
921
922 return 0; /* success return 0 */
923}
924
938uint8_t nrf905_get_tx_address(nrf905_handle_t *handle, uint8_t *addr, uint8_t len)
939{
940 uint8_t res;
941
942 if (handle == NULL) /* check handle */
943 {
944 return 2; /* return error */
945 }
946 if (handle->inited != 1) /* check handle initialization */
947 {
948 return 3; /* return error */
949 }
950 if (len > 4) /* check the result */
951 {
952 handle->debug_print("nrf905: len is over 4.\n"); /* len is over 4 */
953
954 return 4; /* return error */
955 }
956
957 res = a_nrf905_spi_read(handle, NRF905_COMMAND_R_TX_ADDRESS, addr, len); /* read tx address */
958 if (res != 0) /* check result */
959 {
960 handle->debug_print("nrf905: get tx address failed.\n"); /* get tx address failed */
961
962 return 1; /* return error */
963 }
964
965 return 0; /* success return 0 */
966}
967
983{
984 uint8_t res;
985 uint8_t buf[2];
986
987 if (handle == NULL) /* check handle */
988 {
989 return 2; /* return error */
990 }
991 if (handle->inited != 1) /* check handle initialization */
992 {
993 return 3; /* return error */
994 }
995 if (freq > 0x1FF) /* check the result */
996 {
997 handle->debug_print("nrf905: freq is over 0x1FF.\n"); /* freq is over 0x1FF */
998
999 return 4; /* return error */
1000 }
1001
1002 buf[0] = (uint8_t)(NRF905_COMMAND_CHANNEL_CONFIG |
1003 power << 2 | mode << 1 | ((freq >> 8) & 0x1)); /* set buf0 */
1004 buf[1] = (uint8_t)(freq & 0xFF); /* set buf1 */
1005 res = a_nrf905_spi_write(handle, buf[0], &buf[1], 1); /* channel config */
1006 if (res != 0) /* check result */
1007 {
1008 handle->debug_print("nrf905: channel config failed.\n"); /* channel config failed */
1009
1010 return 1; /* return error */
1011 }
1012
1013 return 0; /* success return 0 */
1014}
1015
1027uint8_t nrf905_get_status(nrf905_handle_t *handle, uint8_t *status)
1028{
1029 uint8_t res;
1030 uint8_t reg;
1031
1032 if (handle == NULL) /* check handle */
1033 {
1034 return 2; /* return error */
1035 }
1036 if (handle->inited != 1) /* check handle initialization */
1037 {
1038 return 3; /* return error */
1039 }
1040
1041 reg = 0xFF; /* set 0xFF */
1042 res = a_nrf905_spi_transmit(handle, &reg, (uint8_t *)status, 1); /* read status */
1043 if (res != 0) /* check result */
1044 {
1045 handle->debug_print("nrf905: get status failed.\n"); /* get status failed */
1046
1047 return 1; /* return error */
1048 }
1049
1050 return 0; /* success return 0 */
1051}
1052
1065uint8_t nrf905_set_frequency(nrf905_handle_t *handle, uint16_t freq)
1066{
1067 uint8_t prev;
1068
1069 if (handle == NULL) /* check handle */
1070 {
1071 return 2; /* return error */
1072 }
1073 if (handle->inited != 1) /* check handle initialization */
1074 {
1075 return 3; /* return error */
1076 }
1077 if (freq > 0x1FF) /* check the result */
1078 {
1079 handle->debug_print("nrf905: freq is over 0x1FF.\n"); /* freq is over 0x1FF */
1080
1081 return 4; /* return error */
1082 }
1083
1084 handle->conf[NRF905_REG_CH_NO] = freq & 0xFF; /* set the frequency */
1085 prev = handle->conf[NRF905_REG_CONF1]; /* get the conf1 */
1086 prev &= ~(1 << 0); /* clear the frequency */
1087 prev |= (freq >> 8) & 0x01; /* set the frequency */
1088 handle->conf[NRF905_REG_CONF1] = prev; /* set the conf */
1089
1090 return 0; /* success return 0 */
1091}
1092
1104uint8_t nrf905_get_frequency(nrf905_handle_t *handle, uint16_t *freq)
1105{
1106 uint8_t prev;
1107
1108 if (handle == NULL) /* check handle */
1109 {
1110 return 2; /* return error */
1111 }
1112 if (handle->inited != 1) /* check handle initialization */
1113 {
1114 return 3; /* return error */
1115 }
1116
1117 *freq = 0; /* set freq 0 */
1118 prev = handle->conf[NRF905_REG_CH_NO]; /* set the frequency */
1119 *freq |= prev; /* set the freq */
1120 prev = handle->conf[NRF905_REG_CONF1]; /* get the conf1 */
1121 *freq |= ((uint16_t)prev & 0x01) << 8; /* set the frequency */
1122
1123 return 0; /* success return 0 */
1124}
1125
1137uint8_t nrf905_frequency_convert_to_register(nrf905_handle_t *handle, float mhz, uint16_t *reg)
1138{
1139 uint8_t bw;
1140
1141 if (handle == NULL) /* check handle */
1142 {
1143 return 2; /* return error */
1144 }
1145 if (handle->inited != 1) /* check handle initialization */
1146 {
1147 return 3; /* return error */
1148 }
1149
1150 bw = (handle->conf[NRF905_REG_CONF1] >> 1) & 0x01; /* set bw */
1151 *reg = (uint16_t)(((mhz / (1 + bw)) - 422.4f) * 10.0f); /* convert real data to register data */
1152
1153 return 0; /* success return 0 */
1154}
1155
1167uint8_t nrf905_frequency_convert_to_data(nrf905_handle_t *handle, uint16_t reg, float *mhz)
1168{
1169 uint8_t bw;
1170
1171 if (handle == NULL) /* check handle */
1172 {
1173 return 2; /* return error */
1174 }
1175 if (handle->inited != 1) /* check handle initialization */
1176 {
1177 return 3; /* return error */
1178 }
1179
1180 bw = (handle->conf[NRF905_REG_CONF1] >> 1) & 0x01; /* set bw */
1181 *mhz = (float)(422.4f + (float)reg / 10.0f) * (1 + bw); /* convert real data to register data */
1182
1183 return 0; /* success return 0 */
1184}
1185
1198{
1199 uint8_t prev;
1200
1201 if (handle == NULL) /* check handle */
1202 {
1203 return 2; /* return error */
1204 }
1205 if (handle->inited != 1) /* check handle initialization */
1206 {
1207 return 3; /* return error */
1208 }
1209
1210 prev = handle->conf[NRF905_REG_CONF1]; /* get the conf1 */
1211 prev &= ~(1 << 1); /* clear the config */
1212 prev |= mode << 1; /* set the config */
1213 handle->conf[NRF905_REG_CONF1] = prev; /* set the conf */
1214
1215 return 0; /* success return 0 */
1216}
1217
1230{
1231 uint8_t prev;
1232
1233 if (handle == NULL) /* check handle */
1234 {
1235 return 2; /* return error */
1236 }
1237 if (handle->inited != 1) /* check handle initialization */
1238 {
1239 return 3; /* return error */
1240 }
1241
1242 prev = handle->conf[NRF905_REG_CONF1]; /* get the conf1 */
1243 *mode = (nrf905_pll_mode_t)((prev >> 1) & 0x01); /* get the mode */
1244
1245 return 0; /* success return 0 */
1246}
1247
1260{
1261 uint8_t prev;
1262
1263 if (handle == NULL) /* check handle */
1264 {
1265 return 2; /* return error */
1266 }
1267 if (handle->inited != 1) /* check handle initialization */
1268 {
1269 return 3; /* return error */
1270 }
1271
1272 prev = handle->conf[NRF905_REG_CONF1]; /* get the conf1 */
1273 prev &= ~(3 << 2); /* clear the config */
1274 prev |= output_power << 2; /* set the config */
1275 handle->conf[NRF905_REG_CONF1] = prev; /* set the conf */
1276
1277 return 0; /* success return 0 */
1278}
1279
1292{
1293 uint8_t prev;
1294
1295 if (handle == NULL) /* check handle */
1296 {
1297 return 2; /* return error */
1298 }
1299 if (handle->inited != 1) /* check handle initialization */
1300 {
1301 return 3; /* return error */
1302 }
1303
1304 prev = handle->conf[NRF905_REG_CONF1]; /* get the conf1 */
1305 *output_power = (nrf905_output_power_t)((prev >> 2) & 0x03); /* get the output power */
1306
1307 return 0; /* success return 0 */
1308}
1309
1322{
1323 uint8_t prev;
1324
1325 if (handle == NULL) /* check handle */
1326 {
1327 return 2; /* return error */
1328 }
1329 if (handle->inited != 1) /* check handle initialization */
1330 {
1331 return 3; /* return error */
1332 }
1333
1334 prev = handle->conf[NRF905_REG_CONF1]; /* get the conf1 */
1335 prev &= ~(1 << 4); /* clear the config */
1336 prev |= mode << 4; /* set the config */
1337 handle->conf[NRF905_REG_CONF1] = prev; /* set the conf */
1338
1339 return 0; /* success return 0 */
1340}
1341
1354{
1355 uint8_t prev;
1356
1357 if (handle == NULL) /* check handle */
1358 {
1359 return 2; /* return error */
1360 }
1361 if (handle->inited != 1) /* check handle initialization */
1362 {
1363 return 3; /* return error */
1364 }
1365
1366 prev = handle->conf[NRF905_REG_CONF1]; /* get the conf1 */
1367 *mode = (nrf905_rx_mode_t)((prev >> 4) & 0x01); /* get the mode */
1368
1369 return 0; /* success return 0 */
1370}
1371
1384{
1385 uint8_t prev;
1386
1387 if (handle == NULL) /* check handle */
1388 {
1389 return 2; /* return error */
1390 }
1391 if (handle->inited != 1) /* check handle initialization */
1392 {
1393 return 3; /* return error */
1394 }
1395
1396 prev = handle->conf[NRF905_REG_CONF1]; /* get the conf1 */
1397 prev &= ~(1 << 5); /* clear the config */
1398 prev |= enable << 5; /* set the config */
1399 handle->conf[NRF905_REG_CONF1] = prev; /* set the conf */
1400
1401 return 0; /* success return 0 */
1402}
1403
1416{
1417 uint8_t prev;
1418
1419 if (handle == NULL) /* check handle */
1420 {
1421 return 2; /* return error */
1422 }
1423 if (handle->inited != 1) /* check handle initialization */
1424 {
1425 return 3; /* return error */
1426 }
1427
1428 prev = handle->conf[NRF905_REG_CONF1]; /* get the conf1 */
1429 *enable = (nrf905_bool_t)((prev >> 5) & 0x01); /* get enable */
1430
1431 return 0; /* success return 0 */
1432}
1433
1446{
1447 uint8_t prev;
1448
1449 if (handle == NULL) /* check handle */
1450 {
1451 return 2; /* return error */
1452 }
1453 if (handle->inited != 1) /* check handle initialization */
1454 {
1455 return 3; /* return error */
1456 }
1457
1458 prev = handle->conf[NRF905_REG_CONF2]; /* get the conf2 */
1459 prev &= ~(7 << 0); /* clear the config */
1460 prev |= width << 0; /* set the config */
1461 handle->conf[NRF905_REG_CONF2] = prev; /* set the conf */
1462
1463 return 0; /* success return 0 */
1464}
1465
1478{
1479 uint8_t prev;
1480
1481 if (handle == NULL) /* check handle */
1482 {
1483 return 2; /* return error */
1484 }
1485 if (handle->inited != 1) /* check handle initialization */
1486 {
1487 return 3; /* return error */
1488 }
1489
1490 prev = handle->conf[NRF905_REG_CONF2]; /* get the conf2 */
1491 *width = (nrf905_address_width_t)((prev >> 0) & 0x07); /* get the address width */
1492
1493 return 0; /* success return 0 */
1494}
1495
1508{
1509 uint8_t prev;
1510
1511 if (handle == NULL) /* check handle */
1512 {
1513 return 2; /* return error */
1514 }
1515 if (handle->inited != 1) /* check handle initialization */
1516 {
1517 return 3; /* return error */
1518 }
1519
1520 prev = handle->conf[NRF905_REG_CONF2]; /* get the conf2 */
1521 prev &= ~(7 << 4); /* clear the config */
1522 prev |= width << 4; /* set the config */
1523 handle->conf[NRF905_REG_CONF2] = prev; /* set the conf */
1524
1525 return 0; /* success return 0 */
1526}
1527
1540{
1541 uint8_t prev;
1542
1543 if (handle == NULL) /* check handle */
1544 {
1545 return 2; /* return error */
1546 }
1547 if (handle->inited != 1) /* check handle initialization */
1548 {
1549 return 3; /* return error */
1550 }
1551
1552 prev = handle->conf[NRF905_REG_CONF2]; /* get the conf2 */
1553 *width = (nrf905_address_width_t)((prev >> 4) & 0x07); /* get the address width */
1554
1555 return 0; /* success return 0 */
1556}
1557
1570uint8_t nrf905_set_rx_payload_width(nrf905_handle_t *handle, uint8_t width)
1571{
1572 if (handle == NULL) /* check handle */
1573 {
1574 return 2; /* return error */
1575 }
1576 if (handle->inited != 1) /* check handle initialization */
1577 {
1578 return 3; /* return error */
1579 }
1580 if (width > 0x20) /* check the result */
1581 {
1582 handle->debug_print("nrf905: width is over 0x20.\n"); /* width is over 0x20 */
1583
1584 return 4; /* return error */
1585 }
1586
1587 handle->conf[NRF905_REG_RX_PW] = width; /* set the rx pw */
1588
1589 return 0; /* success return 0 */
1590}
1591
1603uint8_t nrf905_get_rx_payload_width(nrf905_handle_t *handle, uint8_t *width)
1604{
1605 if (handle == NULL) /* check handle */
1606 {
1607 return 2; /* return error */
1608 }
1609 if (handle->inited != 1) /* check handle initialization */
1610 {
1611 return 3; /* return error */
1612 }
1613
1614 *width = handle->conf[NRF905_REG_RX_PW]; /* get the rx pw */
1615
1616 return 0; /* success return 0 */
1617}
1618
1631uint8_t nrf905_set_tx_payload_width(nrf905_handle_t *handle, uint8_t width)
1632{
1633 if (handle == NULL) /* check handle */
1634 {
1635 return 2; /* return error */
1636 }
1637 if (handle->inited != 1) /* check handle initialization */
1638 {
1639 return 3; /* return error */
1640 }
1641 if (width > 0x20) /* check the result */
1642 {
1643 handle->debug_print("nrf905: width is over 0x20.\n"); /* width is over 0x20 */
1644
1645 return 4; /* return error */
1646 }
1647
1648 handle->conf[NRF905_REG_TX_PW] = width; /* set the tx pw */
1649
1650 return 0; /* success return 0 */
1651}
1652
1664uint8_t nrf905_get_tx_payload_width(nrf905_handle_t *handle, uint8_t *width)
1665{
1666 if (handle == NULL) /* check handle */
1667 {
1668 return 2; /* return error */
1669 }
1670 if (handle->inited != 1) /* check handle initialization */
1671 {
1672 return 3; /* return error */
1673 }
1674
1675 *width = handle->conf[NRF905_REG_TX_PW]; /* get the tx pw */
1676
1677 return 0; /* success return 0 */
1678}
1679
1691uint8_t nrf905_set_rx_address(nrf905_handle_t *handle, uint8_t addr[4])
1692{
1693 if (handle == NULL) /* check handle */
1694 {
1695 return 2; /* return error */
1696 }
1697 if (handle->inited != 1) /* check handle initialization */
1698 {
1699 return 3; /* return error */
1700 }
1701
1702 memcpy(&handle->conf[NRF905_REG_RX_ADDRESS_0], addr, 4); /* copy the rx address */
1703
1704 return 0; /* success return 0 */
1705}
1706
1718uint8_t nrf905_get_rx_address(nrf905_handle_t *handle, uint8_t addr[4])
1719{
1720 if (handle == NULL) /* check handle */
1721 {
1722 return 2; /* return error */
1723 }
1724 if (handle->inited != 1) /* check handle initialization */
1725 {
1726 return 3; /* return error */
1727 }
1728
1729 memcpy(addr, &handle->conf[NRF905_REG_RX_ADDRESS_0], 4); /* copy the rx address */
1730
1731 return 0; /* success return 0 */
1732}
1733
1746{
1747 uint8_t prev;
1748
1749 if (handle == NULL) /* check handle */
1750 {
1751 return 2; /* return error */
1752 }
1753 if (handle->inited != 1) /* check handle initialization */
1754 {
1755 return 3; /* return error */
1756 }
1757
1758 prev = handle->conf[NRF905_REG_CONF3]; /* get the conf3 */
1759 prev &= ~(3 << 0); /* clear the config */
1760 prev |= freq << 0; /* set the config */
1761 handle->conf[NRF905_REG_CONF3] = prev; /* set the conf */
1762
1763 return 0; /* success return 0 */
1764}
1765
1778{
1779 uint8_t prev;
1780
1781 if (handle == NULL) /* check handle */
1782 {
1783 return 2; /* return error */
1784 }
1785 if (handle->inited != 1) /* check handle initialization */
1786 {
1787 return 3; /* return error */
1788 }
1789
1790 prev = handle->conf[NRF905_REG_CONF3]; /* get the conf3 */
1791 *freq = (nrf905_output_clock_frequency_t)((prev >> 0) & 0x3); /* get the freq */
1792
1793 return 0; /* success return 0 */
1794}
1795
1808{
1809 uint8_t prev;
1810
1811 if (handle == NULL) /* check handle */
1812 {
1813 return 2; /* return error */
1814 }
1815 if (handle->inited != 1) /* check handle initialization */
1816 {
1817 return 3; /* return error */
1818 }
1819
1820 prev = handle->conf[NRF905_REG_CONF3]; /* get the conf3 */
1821 prev &= ~(1 << 2); /* clear the config */
1822 prev |= enable << 2; /* set the config */
1823 handle->conf[NRF905_REG_CONF3] = prev; /* set the conf */
1824
1825 return 0; /* success return 0 */
1826}
1827
1840{
1841 uint8_t prev;
1842
1843 if (handle == NULL) /* check handle */
1844 {
1845 return 2; /* return error */
1846 }
1847 if (handle->inited != 1) /* check handle initialization */
1848 {
1849 return 3; /* return error */
1850 }
1851
1852 prev = handle->conf[NRF905_REG_CONF3]; /* get the conf3 */
1853 *enable = (nrf905_bool_t)((prev >> 2) & 0x1); /* get the bool value */
1854
1855 return 0; /* success return 0 */
1856}
1857
1870{
1871 uint8_t prev;
1872
1873 if (handle == NULL) /* check handle */
1874 {
1875 return 2; /* return error */
1876 }
1877 if (handle->inited != 1) /* check handle initialization */
1878 {
1879 return 3; /* return error */
1880 }
1881
1882 prev = handle->conf[NRF905_REG_CONF3]; /* get the conf3 */
1883 prev &= ~(7 << 3); /* clear the config */
1884 prev |= freq << 3; /* set the config */
1885 handle->conf[NRF905_REG_CONF3] = prev; /* set the conf */
1886
1887 return 0; /* success return 0 */
1888}
1889
1902{
1903 uint8_t prev;
1904
1905 if (handle == NULL) /* check handle */
1906 {
1907 return 2; /* return error */
1908 }
1909 if (handle->inited != 1) /* check handle initialization */
1910 {
1911 return 3; /* return error */
1912 }
1913
1914 prev = handle->conf[NRF905_REG_CONF3]; /* get the conf3 */
1915 *freq = (nrf905_crystal_oscillator_frequency_t)((prev >> 3) & 0x7); /* get the frequency */
1916
1917 return 0; /* success return 0 */
1918}
1919
1932{
1933 uint8_t prev;
1934
1935 if (handle == NULL) /* check handle */
1936 {
1937 return 2; /* return error */
1938 }
1939 if (handle->inited != 1) /* check handle initialization */
1940 {
1941 return 3; /* return error */
1942 }
1943
1944 prev = handle->conf[NRF905_REG_CONF3]; /* get the conf3 */
1945 prev &= ~(1 << 6); /* clear the config */
1946 prev |= enable << 6; /* set the config */
1947 handle->conf[NRF905_REG_CONF3] = prev; /* set the conf */
1948
1949 return 0; /* success return 0 */
1950}
1951
1964{
1965 uint8_t prev;
1966
1967 if (handle == NULL) /* check handle */
1968 {
1969 return 2; /* return error */
1970 }
1971 if (handle->inited != 1) /* check handle initialization */
1972 {
1973 return 3; /* return error */
1974 }
1975
1976 prev = handle->conf[NRF905_REG_CONF3]; /* get the conf3 */
1977 *enable = (nrf905_bool_t)((prev >> 6) & 0x1); /* get the bool value */
1978
1979 return 0; /* success return 0 */
1980}
1981
1994{
1995 uint8_t prev;
1996
1997 if (handle == NULL) /* check handle */
1998 {
1999 return 2; /* return error */
2000 }
2001 if (handle->inited != 1) /* check handle initialization */
2002 {
2003 return 3; /* return error */
2004 }
2005
2006 prev = handle->conf[NRF905_REG_CONF3]; /* get the conf3 */
2007 prev &= ~(1 << 7); /* clear the config */
2008 prev |= mode << 7; /* set the config */
2009 handle->conf[NRF905_REG_CONF3] = prev; /* set the conf */
2010
2011 return 0; /* success return 0 */
2012}
2013
2026{
2027 uint8_t prev;
2028
2029 if (handle == NULL) /* check handle */
2030 {
2031 return 2; /* return error */
2032 }
2033 if (handle->inited != 1) /* check handle initialization */
2034 {
2035 return 3; /* return error */
2036 }
2037
2038 prev = handle->conf[NRF905_REG_CONF3]; /* get the conf3 */
2039 *mode = (nrf905_crc_mode_t)((prev >> 7) & 0x1); /* get the mode */
2040
2041 return 0; /* success return 0 */
2042}
2043
2057uint8_t nrf905_set_reg(nrf905_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
2058{
2059 if (handle == NULL) /* check handle */
2060 {
2061 return 2; /* return error */
2062 }
2063 if (handle->inited != 1) /* check handle initialization */
2064 {
2065 return 3; /* return error */
2066 }
2067
2068 return a_nrf905_spi_write(handle, reg, buf, len); /* write data */
2069}
2070
2084uint8_t nrf905_get_reg(nrf905_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
2085{
2086 if (handle == NULL) /* check handle */
2087 {
2088 return 2; /* return error */
2089 }
2090 if (handle->inited != 1) /* check handle initialization */
2091 {
2092 return 3; /* return error */
2093 }
2094
2095 return a_nrf905_spi_read(handle, reg, buf, len); /* read data */
2096}
2097
2107{
2108 if (info == NULL) /* check handle */
2109 {
2110 return 2; /* return error */
2111 }
2112
2113 memset(info, 0, sizeof(nrf905_info_t)); /* initialize nrf905 info structure */
2114 strncpy(info->chip_name, CHIP_NAME, 32); /* copy chip name */
2115 strncpy(info->manufacturer_name, MANUFACTURER_NAME, 32); /* copy manufacturer name */
2116 strncpy(info->interface, "SPI", 8); /* copy interface name */
2117 info->supply_voltage_min_v = SUPPLY_VOLTAGE_MIN; /* set minimal supply voltage */
2118 info->supply_voltage_max_v = SUPPLY_VOLTAGE_MAX; /* set maximum supply voltage */
2119 info->max_current_ma = MAX_CURRENT; /* set maximum current */
2120 info->temperature_max = TEMPERATURE_MAX; /* set minimal temperature */
2121 info->temperature_min = TEMPERATURE_MIN; /* set maximum temperature */
2122 info->driver_version = DRIVER_VERSION; /* set driver version */
2123
2124 return 0; /* success return 0 */
2125}
#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]