annotate src/eeprom_rs232.asm @ 654:75e90cd0c2c3

hwOS sport 10.77 release
author heinrichsweikamp
date Thu, 14 Mar 2024 16:56:46 +0100
parents bc214815deb2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
3 ; File eeprom_rs232.asm * combined next generation V3.09.4n
0
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Internal EEPROM, RS232
heinrichsweikamp
parents:
diff changeset
6 ;
654
75e90cd0c2c3 hwOS sport 10.77 release
heinrichsweikamp
parents: 650
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
0
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2011-08-06 : [mH] moving from OSTC code
heinrichsweikamp
parents:
diff changeset
11
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 236
diff changeset
12 #include "hwos.inc"
0
heinrichsweikamp
parents:
diff changeset
13 #include "wait.inc"
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
14 #include "shared_definitions.h"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
15 #include "rtc.inc"
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
16 #include "external_flash.inc"
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
17
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
18 #DEFINE INSIDE_EEPROM_RS232
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
19 #include "eeprom_rs232.inc"
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
20
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
21
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
22 extern lt2942_charge_done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
23
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
24
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
25 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
26 eeprom CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
27 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
28
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
29 ;-----------------------------------------------------------------------------
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
30 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
31 ; EEPROM Functions - for EEPROM Macros and Memory Map, see eeprom_rs232.inc
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
32 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
33 ;-----------------------------------------------------------------------------
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
34
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
35
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
36 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
37 ; Read from internal EEPROM
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
38 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
39 ; Input: EEADRH:EEADR = EEPROM address
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
40 ; Output: EEDATA
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
41 ; Trashed: NONE
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
42 ;
0
heinrichsweikamp
parents:
diff changeset
43 global read_eeprom
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
44 read_eeprom:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
45 bcf EECON1,EEPGD ; access data EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
46 bcf EECON1,CFGS ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
47 bsf EECON1,RD ; initiate reading
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
48 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
49
0
heinrichsweikamp
parents:
diff changeset
50
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
51 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
52 ; Write into internal EEPROM
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
53 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
54 ; Input: EEADRH:EEADR = EEPROM address
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
55 ; EEDATA = byte to write
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
56 ; Trashed: WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
57 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
58 global write_eeprom
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
59 write_eeprom:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
60 bcf EECON1,EEPGD ; access data EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
61 bcf EECON1,CFGS ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
62 bsf EECON1,WREN ; enable writing
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
63 bcf INTCON,GIE ; disable interrupts
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
64 movlw 0x55 ; unlock sequence
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
65 movwf EECON2 ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
66 movlw 0xAA ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
67 movwf EECON2 ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
68 bsf EECON1,WR ; start write operation
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
69 write_eeprom_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
70 btfsc EECON1,WR ; write completed?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
71 bra write_eeprom_loop ; NO - loop waiting
650
bc214815deb2 3.19/10.75 release
heinrichsweikamp
parents: 648
diff changeset
72 btfsc EECON1,WRERR ; All ok?
bc214815deb2 3.19/10.75 release
heinrichsweikamp
parents: 648
diff changeset
73 rcall write_eeprom_error ; NO, something failed.
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
74 bcf EECON1,WREN ; YES - disable writing
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
75 bsf INTCON,GIE ; - re-enable interrupts
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
76 return ; - done
650
bc214815deb2 3.19/10.75 release
heinrichsweikamp
parents: 648
diff changeset
77 write_eeprom_error:
bc214815deb2 3.19/10.75 release
heinrichsweikamp
parents: 648
diff changeset
78 bsf eeprom_write_error_flag ; Set error flag
bc214815deb2 3.19/10.75 release
heinrichsweikamp
parents: 648
diff changeset
79 ; Try again (once)
bc214815deb2 3.19/10.75 release
heinrichsweikamp
parents: 648
diff changeset
80 movlw 0x55 ; unlock sequence
bc214815deb2 3.19/10.75 release
heinrichsweikamp
parents: 648
diff changeset
81 movwf EECON2 ; ...
bc214815deb2 3.19/10.75 release
heinrichsweikamp
parents: 648
diff changeset
82 movlw 0xAA ; ...
bc214815deb2 3.19/10.75 release
heinrichsweikamp
parents: 648
diff changeset
83 movwf EECON2 ; ...
bc214815deb2 3.19/10.75 release
heinrichsweikamp
parents: 648
diff changeset
84 bsf EECON1,WR ; start write operation
bc214815deb2 3.19/10.75 release
heinrichsweikamp
parents: 648
diff changeset
85 write_eeprom_loop2:
bc214815deb2 3.19/10.75 release
heinrichsweikamp
parents: 648
diff changeset
86 btfsc EECON1,WR ; write completed?
bc214815deb2 3.19/10.75 release
heinrichsweikamp
parents: 648
diff changeset
87 bra write_eeprom_loop2 ; NO - loop waiting
bc214815deb2 3.19/10.75 release
heinrichsweikamp
parents: 648
diff changeset
88 return
bc214815deb2 3.19/10.75 release
heinrichsweikamp
parents: 648
diff changeset
89
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
90
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
91 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
92 ; EEPROM read and write Functions to be used via Macros
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
93 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
94 global eeprom_read_common
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
95 eeprom_read_common:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
96 movwf eeprom_loop ; initialize loop counter
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
97 eeprom_read_common_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
98 rcall read_eeprom ; execute read
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
99 movff EEDATA,POSTINC1 ; copy byte from EEPROM data register to memory
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
100 incf EEADR,F ; advance to next EEPROM cell
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
101 decfsz eeprom_loop,F ; decrement loop counter, all done?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
102 bra eeprom_read_common_loop ; NO - loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
103 return ; YES - done
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
104
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
105 global eeprom_write_common
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
106 eeprom_write_common:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
107 movwf eeprom_loop ; initialize loop counter
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
108 eeprom_write_common_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
109 movff POSTINC1,EEDATA ; copy byte from memory to EEPROM data register
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
110 rcall write_eeprom ; execute write
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
111 incf EEADR,F ; advance to next EEPROM cell
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
112 decfsz eeprom_loop,F ; decrement loop counter, all done?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
113 bra eeprom_write_common_loop ; NO - loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
114 return ; YES - done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
115
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
116
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
117 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
118 ; Read OSTC Serial Number
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
119 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
120 global eeprom_serial_number_read
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
121 eeprom_serial_number_read:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
122 EEPROM_II_READ eeprom_ostc_serial,mpr ; read serial number
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
123 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
124
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
125
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
126 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
127 ; Read and Write Dive Number Offset
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
128 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
129 global eeprom_log_offset_read
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
130 eeprom_log_offset_read:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
131 EEPROM_II_READ eeprom_log_offset,mpr ; read log offset
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
132 return ; done
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
133
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
134 global eeprom_log_offset_write
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
135 eeprom_log_offset_write:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
136 EEPROM_II_WRITE mpr,eeprom_log_offset ; write log-offset
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
137 return ; done
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
138
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
139
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
140 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
141 ; Read and Write total Number of Dives
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
142 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
143 global eeprom_total_dives_read
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
144 eeprom_total_dives_read:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
145 EEPROM_II_READ eeprom_num_dives,mpr ; read total dives
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
146 return ; done
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
147
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
148 global eeprom_total_dives_write
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
149 eeprom_total_dives_write:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
150 EEPROM_II_WRITE mpr,eeprom_num_dives ; write total dives
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
151 return ; done
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
152
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
153
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
154 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
155 ; Read and Write the Battery Type and Gauge Reading
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
156 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
157 global eeprom_battery_gauge_read
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
158 eeprom_battery_gauge_read:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
159 ; retrieve battery gauge from EEPROM 0x07-0x0C
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
160 bsf block_battery_gauge ; suspend ISR from accessing the battery gauge
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
161 EEPROM_CC_READ eeprom_battery_type, battery_type ; 1 byte read from EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
162 EEPROM_RR_READ eeprom_battery_gauge,battery_gauge,.6 ; 6 byte read from EEPROM
654
75e90cd0c2c3 hwOS sport 10.77 release
heinrichsweikamp
parents: 650
diff changeset
163 EEPROM_RR_READ eeprom_charge_cycles,charge_cycles,.2 ; 2 byte read from EEPROM
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
164 bcf block_battery_gauge ; allow ISR to access the battery gauge again
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
165 return ; done
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
166
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
167 global eeprom_battery_gauge_write
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
168 eeprom_battery_gauge_write:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
169 bsf block_battery_gauge ; suspend ISR from accessing the battery gauge
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
170 EEPROM_CC_WRITE battery_type, eeprom_battery_type ; 1 byte write to EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
171 update_battery_gauge:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
172 EEPROM_RR_WRITE battery_gauge,eeprom_battery_gauge,.6 ; 6 byte write to EEPROM
654
75e90cd0c2c3 hwOS sport 10.77 release
heinrichsweikamp
parents: 650
diff changeset
173 EEPROM_RR_WRITE charge_cycles,eeprom_charge_cycles,.2 ; 2 byte write to EEPROM
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
174 bcf block_battery_gauge ; allow ISR to access the battery gauge again
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
175 return ; done
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
176
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
177
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
178 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
179 ; Memorize the Checksum of the Firmware in the update Storage
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
180 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
181 global eeprom_memorize_fw_checksum
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
182 eeprom_memorize_fw_checksum:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
183 EXT_FLASH_ADDR 0x3E000D ; address firmware ID at 0x3E000D
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
184 FLASH_CW_READ_0x40 ; read firmware ID to WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
185 movff WREG,buffer+.5 ; append firmware ID to checksum
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
186 EEPROM_RR_WRITE buffer,eeprom_fw_chksum_current,.6 ; do a 6 byte write to EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
187 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
188
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
189
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
190 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
191 ; Read and Write the Deco Status
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
192 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
193 global eeprom_deco_data_read
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
194 eeprom_deco_data_read:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
195
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
196 btfsc RCON,POR ; was there a power outage?
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
197 bra eeprom_deco_data_read_1 ; NO - RTC is up-to-date
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
198
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
199 EEPROM_RR_READ eeprom_deco_data_timestamp,rtc_latched_year,.6 ; 6 byte read from EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
200 call rtc_set_rtc ; recover RTC to last known time & date
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
201
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
202 eeprom_deco_data_read_1:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
203
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
204 ; restore surface interval
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
205 EEPROM_II_READ eeprom_deco_data_surfinterval,mpr ; 2 byte read from EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
206 SMOVII mpr,surface_interval_mins ; ISR-safe copy of surface interval
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
207
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
208 ; bank 3: restore desaturation status
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
209 EEPROM_RR_READ eeprom_deco_data_bank3,0x300,.9 ; 9 byte read from EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
210
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
211 ; bank 5: restore CNS
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
212 EEPROM_RR_READ eeprom_deco_data_bank5,0x500,.4 ; 4 byte read from EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
213
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
214 ; bank 7: restore tissue pressures
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
215 EEPROM_RR_READ eeprom_deco_data_bank7,0x700,.128 ; 128 byte read from EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
216
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
217 return ; done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
218
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
219
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
220 global eeprom_deco_data_write
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
221 eeprom_deco_data_write:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
222
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
223 ; invalidate current data in vault
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
224 movlw DECO_DATA_INVALID_TOKEN ; deco data invalid token
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
225 EEPROM_CC_WRITE WREG,eeprom_deco_data_validity ; 1 byte write to EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
226
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
227 ; store vault version
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
228 movlw eeprom_vault_version ; deco data format version
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
229 EEPROM_CC_WRITE WREG,eeprom_deco_data_version ; 1 byte write to EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
230
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
231 ; store date/time
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
232 SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of date and time
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
233 EEPROM_RR_WRITE rtc_latched_year,eeprom_deco_data_timestamp,.6 ; 6 byte write to EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
234
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
235 ; store surface interval
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
236 SMOVII surface_interval_mins,mpr ; ISR-safe copy of surface interval
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
237 EEPROM_II_WRITE mpr,eeprom_deco_data_surfinterval ; 2 byte write to EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
238
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
239 ; bank 3: store desaturation status
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
240 EEPROM_RR_WRITE 0x300,eeprom_deco_data_bank3,.9 ; 9 byte write to EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
241
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
242 ; bank 5: store CNS
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
243 EEPROM_RR_WRITE 0x500,eeprom_deco_data_bank5,.4 ; 4 byte write to EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
244
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
245 ; bank 7: store tissue pressures
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
246 EEPROM_RR_WRITE 0x700,eeprom_deco_data_bank7,.128 ; 128 byte write to EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
247
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
248 ; indicate new valid data in vault
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
249 movlw DECO_DATA_VALID_TOKEN ; deco data valid token
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
250 EEPROM_CC_WRITE WREG,eeprom_deco_data_validity ; 1 byte write to EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
251
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
252 return ; done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
253
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
254
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
255 ;=============================================================================
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
256 rs232 CODE
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
257 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
258
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
259 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
260 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
261 ; RS232 Functions
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
262 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
263 ;-----------------------------------------------------------------------------
0
heinrichsweikamp
parents:
diff changeset
264
heinrichsweikamp
parents:
diff changeset
265
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
266 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
267 ; Switch-On the IR/S8 Port
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
268 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
269 global enable_ir_s8_analog
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
270 enable_ir_s8_analog:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
271 ;initialize serial port2 (TRISG2)
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
272 btfsc ext_input_s8_ana ; do we have an S8/analog input?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
273 bra enable_s8_analog ; YES - enable S8/analog input
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
274 ;bra enable_ir ; NO - enable IR digital input
0
heinrichsweikamp
parents:
diff changeset
275
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
276 enable_ir:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
277 banksel BAUDCON2 ; select bank for IO register access
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
278 movlw b'00100000' ; speed generator configuration: BRG16=0, inverted for IR
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
279 movwf BAUDCON2 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
280 movlw b'00100000' ; TX configuration: BRGH=0, SYNC=0
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
281 movwf TXSTA2 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
282 movlw .102 ; speed configuration: SPBRGH:SPBRG = .102 : 2403 BAUD @ 16 MHz
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
283 movwf SPBRG2 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
284 clrf SPBRGH2 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
285 movlw b'10010000' ; RX configuration
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
286 movwf RCSTA2 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
287 banksel common ; back to bank common
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
288 bsf ir_power ; power-up IR
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
289 btfss ir_power ; power-up confirmed?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
290 bra $-6 ; NO - loop and wait
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
291 bsf PIE3,RC2IE ; enable RC2 INT
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
292 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
293
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
294 enable_s8_analog:
629
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
diff changeset
295 banksel TXSTA2 ; select bank for IO register access
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
296 clrf TXSTA2 ; reset UART 2 TX function
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
297 clrf RCSTA2 ; reset UART 2 RX function
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
298 banksel common ; back to bank common
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
299
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
300 bsf mcp_power ; power-up instrumentation amp (used by S8 and analog input)
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
301 btfss mcp_power ; power-up completed?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
302 bra $-4 ; NO - loop
113
heinrichsweikamp
parents: 0
diff changeset
303
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
304 ; branch according to S8 / analog selection
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
305 TSTOSS opt_s8_mode ; =0: analog, =1: digital RS232
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
306 bra enable_analog ; -> analog
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
307
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
308 ; configure S8 digital interface
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
309 bcf s8_npower ; power S8 HUD (inverted via P-MOS transistor)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
310 WAITMS d'30' ; NO - wait 30 ms
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
311 banksel BAUDCON2 ; select bank for IO register access
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
312 movlw b'00000000' ; speed generator configuration: BRG16=0, normal for S8
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
313 movwf BAUDCON2 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
314 movlw b'00100000' ; TX configuration: BRGH=0, SYNC=0
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
315 movwf TXSTA2 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
316 movlw .25 ; speed configuration: SPBRGH:SPBRG = .25 : 9615 BAUD @ 16 MHz
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
317 movwf SPBRG2 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
318 movlw b'10010000' ; RX configuration
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
319 movwf RCSTA2 ; ...
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
320 banksel common ; back to bank common
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
321 bsf PIE3,RC2IE ; enable RC2 INT
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
322 return
113
heinrichsweikamp
parents: 0
diff changeset
323
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
324 enable_analog:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
325 ; S8 analog interface
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
326 bcf PIE3,RC2IE ; disable RC2 INT
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
327 bsf s8_npower ; power-down S8 digital interface
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
328 return ; done
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
329
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
330
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
331 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
332 ; Shut-Down the IR/S8 Port
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
333 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
334 global disable_ir_s8_analog
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
335 disable_ir_s8_analog:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
336 banksel TXSTA2 ; select bank for IO register access
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
337 clrf TXSTA2 ; shut down TX function
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
338 clrf RCSTA2 ; shut down RX function
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
339 banksel common ; back to bank common
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
340 bcf PIE3,RC2IE ; disable RC2 INT
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
341 bcf ir_power ; power down IR receiver
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
342 bcf mcp_power ; power-down instrumentation amp
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
343 bsf s8_npower ; power-down S8 digital interface
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
344 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
345
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
346
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
347 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
348 ; Send Byte in WREG via the IR/S8 Port
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
349 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
350 global ir_s8_tx_single
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
351 ir_s8_tx_single:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
352 banksel TXSTA2 ; UART 2 is outside of the access RAM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
353 movwf TXREG2 ; transmit byte
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
354 ir_s8_tx_single_loop:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
355 btfss TXSTA2,TRMT ; TX completed?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
356 bra ir_s8_tx_single_loop ; NO - wait...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
357 banksel common ; YES - back to bank common
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
358 return ; - done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
359
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
360
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
361 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
362 ; Switch-On USB/BT Port
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
363 ;
0
heinrichsweikamp
parents:
diff changeset
364 global enable_rs232
heinrichsweikamp
parents:
diff changeset
365 enable_rs232:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
366 call request_speed_normal ; request CPU speed change to normal speed
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
367 enable_rs232_1:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
368 btfss speed_is_normal ; speed = normal?
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
369 bra enable_rs232_1 ; NO - loop waiting for ISR to have adjusted the speed
640
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
370 bsf TRISC,7
654
75e90cd0c2c3 hwOS sport 10.77 release
heinrichsweikamp
parents: 650
diff changeset
371 bcf ble_npower ; YES - switch port to comm
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
372 bsf PORTJ,2 ; - /Reset (required for very old OSTC sport)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
373 movlw b'00100100' ; - TX configuration: TX enabled, async, high speed
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
374 movwf TXSTA1 ; - ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
375 movlw b'10010000' ; - RX configuration: port enabled, RX enabled
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
376 movwf RCSTA1 ; - ...
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
377 IFNDEF _comm_debug
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
378 movlw HIGH(.65536-rx_timeout*.32) ; - define TMR5H initialization value for RX timeout (rx_timeout defined in hwos.inc)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
379 ELSE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
380 include "math.inc"
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
381 movff opt_comm_timeout,xA+0 ; - get timeout setting in multiples of 10 ms (opt_comm_timeout: 10 .. 200 x 10 ms)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
382 clrf xA+1 ; - ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
383 MOVLI .320,xB ; - multiply with 10 to get timeout in ms and 32 because tmr5 ticks 32x per ms
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
384 call mult16x16 ; - xC = xA * xB = timer ticks to go until timeout
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
385 MOVII xC,sub_b ; - multiplication result is max. 64000
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
386 MOVLI .65535,sub_a ; - timer wraps around after 65535
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
387 call subU16 ; - sub_c = sub_a - sub_b = start value for timer
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
388
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
389 movlw .244 ; safety maximum value for rx_timeout_tmr5h_load (minimum timeout interval)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
390 cpfslt sub_c+1 ; result > safety value?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
391 movwf sub_c+1 ; YES - revert to safety value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
392
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
393 movf sub_c+1,W ; - keep only the upper byte as TMR5H initialization value for RX timeout
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
394 ENDIF
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
395 movwf rx_timeout_tmr5h_load ; - store for later use
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
396 return ; - done
0
heinrichsweikamp
parents:
diff changeset
397
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
398
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
399 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
400 ; Shut-Down USB/BT Port
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
401 ;
0
heinrichsweikamp
parents:
diff changeset
402 global disable_rs232
heinrichsweikamp
parents:
diff changeset
403 disable_rs232:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
404 clrf RCSTA1 ; disable RX
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
405 clrf TXSTA1 ; disable TX
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
406 bcf PORTC,6 ; switch TX pin hard to GND
654
75e90cd0c2c3 hwOS sport 10.77 release
heinrichsweikamp
parents: 650
diff changeset
407 bsf ble_npower ; power down BT chip
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
408 bcf PORTJ,2 ; /Reset (required for very old OSTC sport)
640
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
409 bcf TRISC,7
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
410 bcf PORTC,7 ; switch RX pin hard to GND
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
411 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
412
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
413
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
414 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
415 ; Wait for last Byte to be sent out of USB/BT Port
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
416 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
417 global rs232_wait_tx ; ++++ do not touch WREG here! ++++
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
418 rs232_wait_tx:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
419 btfss TXSTA1,TRMT ; last byte completely shifted out on TX pin?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
420 bra rs232_wait_tx ; NO - wait...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
421 btfss ble_available ; YES - OSTC running with Bluetooth?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
422 return ; NO - done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
423 btfsc NRTS ; YES - Bluetooth module also completed TX?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
424 bra rs232_wait_tx ; NO - wait...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
425 return ; YES - done
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
426
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
427
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
428 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
429 ; Receive one Byte via the USB/BT Port
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
430 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
431 ; ++++ make this code as fast as possible! ++++
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
432 ; ++++ do not touch WREG here! ++++
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
433 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
434 global serial_rx_single
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
435 serial_rx_single:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
436 bcf rs232_rx_timeout ; clear timeout flag
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
437 btfsc PIR1,RCIF ; received a data byte? (bit is set on RX completion and reset on reading RCREG1)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
438 return ; YES - done (fast path)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
439 movff rx_timeout_tmr5h_load,TMR5H ; NO - load TMR5 high with timeout value
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
440 clrf TMR5L ; - load TMR5 low with a zero, writing low starts the timer
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
441 bcf PIR5,TMR5IF ; - clear timer overflow flag
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
442 serial_rx_single_loop:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
443 btfsc PIR1,RCIF ; received a data byte?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
444 return ; YES - done
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
445 btfss PIR5,TMR5IF ; NO - timer overflow (timeout)?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
446 bra serial_rx_single_loop ; NO - continue waiting
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
447 ;bra serial_rx_timeout ; YES - timeout
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
448
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
449
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
450 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
451 ; Helper Function: Timeout in serial_rx_single / serial_tx_steam
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
452 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
453 serial_rx_timeout:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
454 bsf rs232_rx_timeout ; set timeout flag
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
455 bcf RCSTA1,CREN ; clear receiver status: disable RX,
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
456 bsf RCSTA1,CREN ; ... enable again RX
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
457 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
458
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
459
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
460 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
461 ; Send and Receive Functions to be used via Macros
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
462 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
463
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
464 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
465 ; Send a Range of 1-256 Bytes from Memory via the USB/BT Port
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
466 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
467 global serial_tx_steam
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
468 serial_tx_steam:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
469 movwf eeprom_loop ; initialize loop counter (eeprom variable used here)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
470 serial_tx_ram_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
471 rcall rs232_wait_tx ; wait for completion of last transmit
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
472 movff POSTINC2,TXREG1 ; send a byte from memory to serial
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
473 decfsz eeprom_loop,F ; decrement loop counter, became zero?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
474 bra serial_tx_ram_loop ; NO - loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
475 return ; YES - done
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
476
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
477
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
478 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
479 ; Receive a Range of 1-256 Byte via the USB/BT Port and write them to Memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
480 ; ++++ make this code as fast as possible! ++++
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
481 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
482 global serial_rx_stream
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
483 serial_rx_stream:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
484 movwf eeprom_loop ; initialize loop counter (eeprom variable used here)
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
485 serial_rx_stream_loop:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
486 btfss PIR1,RCIF ; received a data byte? (bit is set on RX complete and reset on reading RCREG1)
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
487 bra serial_rx_stream_tmr ; NO - enter receive loop with timeout
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
488 ;bra serial_rx_stream_received ; YES - copy to memory, tick counter, ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
489
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
490 serial_rx_stream_received:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
491 movff RCREG1,POSTINC2 ; copy received byte to memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
492 decfsz eeprom_loop,F ; decrement loop counter, became zero?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
493 bra serial_rx_stream_loop ; NO - await next byte
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
494 bcf rs232_rx_timeout ; YES - clear timeout flag
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
495 return ; - all bytes received, done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
496
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
497 serial_rx_stream_tmr:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
498 movff rx_timeout_tmr5h_load,TMR5H ; load TMR5 high with timeout value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
499 clrf TMR5L ; load TMR5 low with a zero, writing to low starts the timer
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
500 bcf PIR5,TMR5IF ; clear timer overflow flag
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
501 serial_rx_stream_tmr_loop:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
502 btfsc PIR1,RCIF ; received a data byte? (bit is set on RX complete and reset on reading RCREG1)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
503 bra serial_rx_stream_received ; YES - copy to memory, tick counter, ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
504 btfss PIR5,TMR5IF ; NO - timer overflow (timeout)?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
505 bra serial_rx_stream_tmr_loop ; NO - continue waiting
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
506 bra serial_rx_timeout ; YES - timeout
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
507
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
508 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
509
648
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
510 ;-----------------------------------------------------------------------------
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
511 ; Add new services and characteristics to new BLE (type 2) module
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
512 ;-----------------------------------------------------------------------------
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
513 global ble2_configure
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
514 ble2_configure:
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
515 rcall enable_rs232
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
516 bcf NCTS ; Clear to send
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
517 call wait_1s
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
518 call wait_1s
650
bc214815deb2 3.19/10.75 release
heinrichsweikamp
parents: 648
diff changeset
519 call wait_1s
bc214815deb2 3.19/10.75 release
heinrichsweikamp
parents: 648
diff changeset
520 call wait_1s
648
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
521 bcf PORTB,6
650
bc214815deb2 3.19/10.75 release
heinrichsweikamp
parents: 648
diff changeset
522 nop
648
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
523 bsf PORTB,6 ; rising edge -> Command mode
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
524
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
525 ; point to config table
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
526 movlw LOW ble_AT1
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
527 movwf TBLPTRL
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
528 movlw HIGH ble_AT1
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
529 movwf TBLPTRH
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
530 movlw UPPER ble_AT1
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
531 movwf TBLPTRU
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
532 rcall ble_init_loop
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
533
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
534 rcall disable_rs232
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
535 bcf PORTB,6 ; keep low for min. current consumption
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
536 return ; done.
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
537
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
538 ble_init_loop:
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
539 TBLRD*+
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
540 movlw 0xFF ; end
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
541 cpfseq TABLAT
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
542 bra ble_init_loop1 ; not end
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
543 ; quit (return)
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
544 return ; done.
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
545 ble_init_loop1:
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
546 movlw 0xFE ; WAIT 20ms
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
547 cpfseq TABLAT
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
548 bra ble_init_loop2 ; not wait 20ms
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
549 WAITMS d'20'
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
550 bra ble_init_loop
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
551 ble_init_loop2:
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
552 movlw 0xFD ; WAIT 1s
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
553 cpfseq TABLAT
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
554 bra ble_init_loop3 ; not wait 1s
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
555 call wait_1s
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
556 bra ble_init_loop
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
557 ble_init_loop3:
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
558 movf TABLAT,W
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
559 SERIAL_CC_SEND WREG
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
560 bra ble_init_loop
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
561
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
562 ble_AT1: ; config table
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
563 ; 0xFF at the end
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
564 ; 0xFE: 20ms delay
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
565 ; 0xFD: 1s delay
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
566 ; .13: cr character
650
bc214815deb2 3.19/10.75 release
heinrichsweikamp
parents: 648
diff changeset
567 db 0xFD,0xFD,0xFD,0xFD ; Wait 4 seconds
648
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
568 db "AT+UDSC=0,0",.13,0xFE,0xFE ; Disable SPP Server on ID0 (and wait 40ms)
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
569 db "AT+UDSC=0,3",.13,0xFE,0xFE ; SPP Server on ID0 (and wait 40ms)
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
570 db "AT+UDSC=1,0",.13,0xFE,0xFE ; Disable SPS Server on ID1 (and wait 40ms)
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
571 db "AT+UDSC=1,6",.13,0xFE,0xFE ; SPS Server on ID1 (and wait 40ms)
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
572 db "AT&W",.13,0xFE ; write settings into eeprom (and wait 20ms)
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
573 db "AT+CPWROFF",.13,0xFD,0xFD,0xFF ; save and reboot (and wait 2 seconds)
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
574
aeca5717d9eb 3.17 / 10.72 release
heinrichs weikamp
parents: 640
diff changeset
575
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
576 END