@@ -78,24 +78,24 @@ uint8_t adamnet_checksum(uint8_t *buf, unsigned short len)
7878void virtualDevice::adamnet_send (uint8_t b)
7979{
8080 // Write the byte
81- fnUartBUS .write (b);
82- fnUartBUS .flush ();
81+ SYSTEM_BUS .write (b);
82+ SYSTEM_BUS .flush ();
8383}
8484
8585void virtualDevice::adamnet_send_buffer (uint8_t *buf, unsigned short len)
8686{
87- fnUartBUS .write (buf, len);
88- fnUartBUS .flush ();
87+ SYSTEM_BUS .write (buf, len);
88+ SYSTEM_BUS .flush ();
8989}
9090
9191uint8_t virtualDevice::adamnet_recv ()
9292{
9393 uint8_t b;
9494
95- while (fnUartBUS .available () <= 0 )
95+ while (SYSTEM_BUS .available () <= 0 )
9696 fnSystem.yield ();
9797
98- b = fnUartBUS .read ();
98+ b = SYSTEM_BUS .read ();
9999
100100 return b;
101101}
@@ -108,17 +108,17 @@ bool virtualDevice::adamnet_recv_timeout(uint8_t *b, uint64_t dur)
108108 start = current = esp_timer_get_time ();
109109 elapsed = 0 ;
110110
111- while (fnUartBUS .available () <= 0 )
111+ while (SYSTEM_BUS .available () <= 0 )
112112 {
113113 current = esp_timer_get_time ();
114114 elapsed = current - start;
115115 if (elapsed > dur)
116116 break ;
117117 }
118118
119- if (fnUartBUS .available () > 0 )
119+ if (SYSTEM_BUS .available () > 0 )
120120 {
121- *b = (uint8_t )fnUartBUS .read ();
121+ *b = (uint8_t )SYSTEM_BUS .read ();
122122 timeout = false ;
123123 } // else
124124 // Debug_printf("duration: %llu\n", elapsed);
@@ -143,7 +143,7 @@ void virtualDevice::adamnet_send_length(uint16_t l)
143143
144144unsigned short virtualDevice::adamnet_recv_buffer (uint8_t *buf, unsigned short len)
145145{
146- return fnUartBUS. readBytes (buf, len);
146+ return SYSTEM_BUS. read (buf, len);
147147}
148148
149149uint32_t virtualDevice::adamnet_recv_blockno ()
@@ -168,7 +168,7 @@ void virtualDevice::adamnet_response_ack(bool doNotWaitForIdle)
168168 {
169169 SYSTEM_BUS.wait_for_idle ();
170170 }
171-
171+
172172 if (t < 300 )
173173 {
174174 adamnet_send (0x90 | _devnum);
@@ -183,7 +183,7 @@ void virtualDevice::adamnet_response_nack(bool doNotWaitForIdle)
183183 {
184184 SYSTEM_BUS.wait_for_idle ();
185185 }
186-
186+
187187 if (t < 300 )
188188 {
189189 adamnet_send (0xC0 | _devnum);
@@ -203,12 +203,12 @@ void systemBus::wait_for_idle()
203203 do
204204 {
205205 // Wait for serial line to quiet down.
206- while (fnUartBUS .available () > 0 )
207- fnUartBUS .read ();
206+ while (_port .available () > 0 )
207+ _port .read ();
208208
209209 start = current = esp_timer_get_time ();
210210
211- while ((fnUartBUS .available () <= 0 ) && (isIdle == false ))
211+ while ((_port .available () <= 0 ) && (isIdle == false ))
212212 {
213213 current = esp_timer_get_time ();
214214 dur = current - start;
@@ -221,7 +221,7 @@ void systemBus::wait_for_idle()
221221
222222void virtualDevice::adamnet_process (uint8_t b)
223223{
224- fnUartDebug .printf (" adamnet_process() not implemented yet for this device. Cmd received: %02x\n " , b);
224+ fnDebugConsole .printf (" adamnet_process() not implemented yet for this device. Cmd received: %02x\n " , b);
225225}
226226
227227void virtualDevice::adamnet_control_status ()
@@ -262,14 +262,14 @@ void virtualDevice::adamnet_idle()
262262
263263// void virtualDevice::adamnet_status()
264264// {
265- // fnUartDebug .printf("adamnet_status() not implemented yet for this device.\n");
265+ // fnDebugConsole .printf("adamnet_status() not implemented yet for this device.\n");
266266// }
267267
268268void systemBus::_adamnet_process_cmd ()
269269{
270270 uint8_t b;
271271
272- b = fnUartBUS .read ();
272+ b = _port .read ();
273273 start_time = esp_timer_get_time ();
274274
275275 uint8_t d = b & 0x0F ;
@@ -311,7 +311,7 @@ void systemBus::service()
311311 _adamnet_process_queue ();
312312
313313 // Process anything waiting.
314- if (fnUartBUS .available () > 0 )
314+ if (_port .available () > 0 )
315315 _adamnet_process_cmd ();
316316}
317317
@@ -332,7 +332,7 @@ void systemBus::setup()
332332 gpio_isr_handler_add ((gpio_num_t )PIN_ADAMNET_RESET, adamnet_reset_isr_handler, (void *)PIN_CARD_DETECT_FIX);
333333
334334 // Set up UART
335- fnUartBUS .begin (ADAMNET_BAUDRATE);
335+ _port .begin (ADAMNET_BAUDRATE);
336336}
337337
338338void systemBus::shutdown ()
0 commit comments