nRF_Initialize

Purpose: Power down the nRF24L01+ chip, load its Registers with the default configuration, then power it back up.
Assumes:   There may not be an nRF24L01+ chip attached; if not, ignore the command (i.e, handle it gracefully; don't crash!)
Passed: Nothing.
Returns: R25   BYTE   bnRF_Reg0Read   value read back from nRF REG_0_CONFIG before PWR_UP (also in R0)
Alters: R0, R20, R22, R23, R24, R25, R30, R31, and the FLAGs (SREG)
Example:  
.ORG 0x1000

   CALL    ADumpRegisters         ; Include a selectable Register Dump both
   CALL    AnRF_Initialize        ;  before and after the nRF_Initialize() call
   CALL    ADumpRegisters         ;  to be able to check the return value
   RET
Test it:
>N  ; An an nRF Register dump, without a nRF24L01+ installed:
0x00 (FF) -> 0xFF = B11111111
0x01 (FF) -> 0xFF = B11111111
0x02 (FF) -> 0xFF = B11111111
0x03 (FF) -> 0xFF = B11111111
0x04 (FF) -> 0xFF = B11111111
0x05 (FF) -> 0xFF = B11111111
0x06 (FF) -> 0xFF = B11111111
0x07 (FF) -> 0xFF = B11111111
0x08 (FF) -> 0xFF = B11111111
0x09 (FF) -> 0xFF = B11111111
0x0A (FF) -> 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
0x0B (FF) -> 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
0x0C (FF) -> 0xFF = B11111111
0x0D (FF) -> 0xFF = B11111111
0x0E (FF) -> 0xFF = B11111111
0x0F (FF) -> 0xFF = B11111111
0x10 (FF) -> 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
0x11 (FF) -> 0xFF = B11111111
0x12 (FF) -> 0xFF = B11111111
0x13 (FF) -> 0xFF = B11111111
0x14 (FF) -> 0xFF = B11111111
0x15 (FF) -> 0xFF = B11111111
0x16 (FF) -> 0xFF = B11111111
0x17 (FF) -> 0xFF = B11111111
0x1C (FF) -> 0xFF = B11111111
0x1D (FF) -> 0xFF = B11111111
>
>n  ; After installing an nRF24L01+, prior to any initialize command:
0x00 (0E) -> 0x0A = B00001010
0x01 (0E) -> 0x3F = B00111111
0x02 (0E) -> 0x03 = B00000011
0x03 (0E) -> 0x03 = B00000011
0x04 (0E) -> 0x03 = B00000011
0x05 (0E) -> 0x02 = B00000010
0x06 (0E) -> 0x0F = B00001111
0x07 (0E) -> 0x0E = B00001110
0x08 (0E) -> 0x00 = B00000000
0x09 (0E) -> 0x00 = B00000000
0x0A (0E) -> 0xE7, 0xE7, 0xE7, 0xE7, 0xE7
0x0B (0E) -> 0xC2, 0xC2, 0xC2, 0xC2, 0xC2
0x0C (0E) -> 0xC3 = B11000011
0x0D (0E) -> 0xC4 = B11000100
0x0E (0E) -> 0xC5 = B11000101
0x0F (0E) -> 0xC6 = B11000110
0x10 (0E) -> 0xE7, 0xE7, 0xE7, 0xE7, 0xE7
0x11 (0E) -> 0x00 = B00000000
0x12 (0E) -> 0x00 = B00000000
0x13 (0E) -> 0x00 = B00000000
0x14 (0E) -> 0x00 = B00000000
0x15 (0E) -> 0x00 = B00000000
0x16 (0E) -> 0x00 = B00000000
0x17 (0E) -> 0x11 = B00010001
0x1C (0E) -> 0x00 = B00000000
0x1D (0E) -> 0x00 = B00000000
>           ; Must be in Manager mode to use the '@' command; logon
m>@ 0x1000  ; Run our test routine, which calls nRF_Initialize()
m>N         ; The contents of the nRF Registers after the call:
0x00 (0E) -> 0x7E = B01111110
0x01 (0E) -> 0x3F = B00111111
0x02 (0E) -> 0x3F = B00111111
0x03 (0E) -> 0x03 = B00000011
0x04 (0E) -> 0x34 = B00110100
0x05 (0E) -> 0x4E = B01001110
0x06 (0E) -> 0x06 = B00000110
0x07 (0E) -> 0x0E = B00001110
0x08 (0E) -> 0x00 = B00000000
0x09 (0E) -> 0x00 = B00000000
0x0A (0E) -> 0x32, 0x44, 0x65, 0x6D, 0x6F
0x0B (0E) -> 0x31, 0x44, 0x65, 0x6D, 0x6F
0x0C (0E) -> 0x33 = B00110011
0x0D (0E) -> 0x34 = B00110100
0x0E (0E) -> 0x35 = B00110101
0x0F (0E) -> 0x36 = B00110110
0x10 (0E) -> 0x32, 0x44, 0x65, 0x6D, 0x6F
0x11 (0E) -> 0x00 = B00000000
0x12 (0E) -> 0x00 = B00000000
0x13 (0E) -> 0x00 = B00000000
0x14 (0E) -> 0x00 = B00000000
0x15 (0E) -> 0x00 = B00000000
0x16 (0E) -> 0x00 = B00000000
0x17 (0E) -> 0x11 = B00010001
0x1C (0E) -> 0x3F = B00111111
0x1D (0E) -> 0x07 = B00000111
m>
m>DE+ 0x38 2  ; Pointer to the default nRF configuration in EEPROM:
EEPROM contents:
0030:                         -60 00                            `.
m>DE+- 0x50 48    ; The demo default nRF Transmitter configuration:
0050:  6E 52 46 20 50 54 58 20-63 6F 6E 66 69 67 3A 00  nRF PTX config:.
0060:  7C 3F 3F 03 34 4E 06 32-44 65 6D 6F 31 44 65 6D  |??.4N.2Demo1Dem
0070:  6F 33 34 35 36 32 44 65-6D 6F 3F 07 88 D0 07 00  o34562Demo?.....
m>DE-+ 0x80 48    ; The demo default nRF Receiver configuration:
0080:  6E 52 46 20 50 52 58 20-63 6F 6E 66 69 67 3A 00  nRF PRX config:.
0090:  7D 00 3F 03 34 4E 06 32-44 65 6D 6F 31 44 65 6D  }.?.4N.2Demo1Dem
00A0:  6F 33 34 35 36 32 44 65-6D 6F 3F 07 88 D0 07 00  o34562Demo?.....
m>EW 0x38 += 0x30  ; Change EEptrNRF24L01Cfg to 0x0090
m>DE+- 0x38 2      ; Verify before proceeding:
0030:                         -90 00                            ..
m>  ; Turn on the selectable Register Dump ('}' as 1st character)
m>@ 0x1000   ; Run the test routine containing the nRF_Initialize() call

 10   32   54   76   98  1110 1312 1514 1716 1918 2120 2322 2524 2726 2928 3130  SP  RetAdd   SREG
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ --------
0000 0499 09F7 FF28-0004 0000 0000 4000-0021 007F 4011 3020-940F 0230 0280 1780 08F1  2F04  ItHsVNzc
0000 0499 09F7 FF28-0004 0000 0000 4000-0021 2000 0D10 0800-0000 0239 0280 0800 08F5  1004  IthsvnZc
007D 0499 09F7 FF28-0004 0000 0000 4000-0021 2000 0D00 1200-7D0E 0239 0280 0090 08F5  100C  IthsvnZC
m>  ; The value in R0 and R25 is the value set in nRF REG_0_CONFIG,
m>  ;  with the exception of the PWR_UP BIT, which nRF_Initialize() set
m>N ; Turn off the MCU Register Dump; read and show all nRF Registers:
0x00 (0E) -> 0x7F = B01111111
0x01 (0E) -> 0x00 = B00000000
0x02 (0E) -> 0x3F = B00111111
0x03 (0E) -> 0x03 = B00000011
0x04 (0E) -> 0x34 = B00110100
0x05 (0E) -> 0x4E = B01001110
0x06 (0E) -> 0x06 = B00000110
0x07 (0E) -> 0x0E = B00001110
0x08 (0E) -> 0x00 = B00000000
0x09 (0E) -> 0x00 = B00000000
0x0A (0E) -> 0x32, 0x44, 0x65, 0x6D, 0x6F
0x0B (0E) -> 0x31, 0x44, 0x65, 0x6D, 0x6F
0x0C (0E) -> 0x33 = B00110011
0x0D (0E) -> 0x34 = B00110100
0x0E (0E) -> 0x35 = B00110101
0x0F (0E) -> 0x36 = B00110110
0x10 (0E) -> 0x32, 0x44, 0x65, 0x6D, 0x6F
0x11 (0E) -> 0x00 = B00000000
0x12 (0E) -> 0x00 = B00000000
0x13 (0E) -> 0x00 = B00000000
0x14 (0E) -> 0x00 = B00000000
0x15 (0E) -> 0x00 = B00000000
0x16 (0E) -> 0x00 = B00000000
0x17 (0E) -> 0x11 = B00010001
0x1C (0E) -> 0x3F = B00111111
0x1D (0E) -> 0x07 = B00000111
m>                                                                                                   
Notes:The System Variable EEptrNRF24L01Cfg in EEPROM is the pointer to the default nRF configuration, also in EEPROM.
The "N*" command performs the same initialization as nRF_Initialize(), which is:
   1) Clear the PWR_UP bit in nRF24L01+ REG_0_CONFIG,
   2) Read the default configuration specified by EEptrNRF24L01Cfg,
   3) Load each nRF24L01+ Register with the values read, and
   4) Set the PWR_UP bit in REG_0_CONFIG.
The "NI" command performs almost the same steps, but leaves the PWR_UP bit in the state last selected (and was then saved in the BIT_NRF_POWER_CMD in System Variable bFlags_nRF.)
For more information about the nRF24L01+ radio microchip, please refer to the Nordic Semiconductor ® nRF24L01+ Product Specification, version 1.0, dated September, 2008.
Dropin: 
(setup
code)
;   Setup for the NRF_Initialize() call:
; Passed:  Nothing.
; Returns: R25 (= R0) the value read back from nRF REG_0_CONFIG before PWR_UP
; Alters:  R0, R20, R22, R23, R24, R25, R30, R31, and the FLAGs (SREG)
Also see:  The Nordic nRF24L01 radio script commands.