@@ -116,11 +116,13 @@ void IRAM_ATTR systemBus::cbm_on_clk_isr_handler()
116116 else
117117 {
118118 newIO (val);
119+ #ifdef JIFFYDOS
119120 if (flags & JIFFYDOS_ACTIVE)
120121 {
121122 detected_protocol = PROTOCOL_JIFFYDOS;
122123 protocol = selectProtocol ();
123124 }
125+ #endif
124126 }
125127 break ;
126128
@@ -210,8 +212,7 @@ static void ml_iec_intr_task(void* arg)
210212 if ( IEC.enabled )
211213 IEC.service();
212214
213- if ( IEC.state < BUS_ACTIVE )
214- taskYIELD();
215+ taskYIELD();
215216 }
216217}
217218#endif
@@ -226,43 +227,6 @@ void systemBus::init_gpio(gpio_num_t _pin)
226227 return ;
227228}
228229
229- bool IRAM_ATTR systemBus::status ()
230- {
231- // uint64_t pin_states;
232- // pin_states = REG_READ(GPIO_IN1_REG);
233- // pin_states << 32 & REG_READ(GPIO_IN_REG);
234- // pin_atn = pin_states & BIT(PIN_IEC_ATN);
235- // pin_clk = pin_states & BIT(PIN_IEC_CLK_IN);
236- // pin_data = pin_states & BIT(PIN_IEC_DATA_IN);
237- // pin_srq = pin_states & BIT(PIN_IEC_SRQ);
238- // pin_reset = pin_states & BIT(PIN_IEC_RESET);
239- return true ;
240- };
241-
242- // uint8_t IRAM_ATTR systemBus::status()
243- // {
244- // int data = 0;
245-
246- // // gpio_config_t io_config =
247- // // {
248- // // .pin_bit_mask = BIT(PIN_IEC_CLK_IN) | BIT(PIN_IEC_CLK_OUT) |BIT(PIN_IEC_DATA_IN) | BIT(PIN_IEC_DATA_OUT) | BIT(PIN_IEC_SRQ) | BIT(PIN_IEC_RESET),
249- // // .mode = GPIO_MODE_INPUT,
250- // // .pull_up_en = GPIO_PULLUP_ENABLE,
251- // // .intr_type = GPIO_INTR_DISABLE,
252- // // };
253-
254- // // ESP_ERROR_CHECK(gpio_config(&io_config));
255- // uint64_t io_data = REG_READ(GPIO_IN_REG);
256-
257- // //data |= (0 & (io_data & (1 << PIN_IEC_ATN)));
258- // data |= (1 & (io_data & (1 << PIN_IEC_CLK_IN)));
259- // data |= (2 & (io_data & (1 << PIN_IEC_DATA_IN)));
260- // data |= (3 & (io_data & (1 << PIN_IEC_SRQ)));
261- // data |= (4 & (io_data & (1 << PIN_IEC_RESET)));
262-
263- // return data;
264- // }
265-
266230void systemBus::setup ()
267231{
268232 Debug_printf (" IEC systemBus::setup()\r\n " );
@@ -285,6 +249,8 @@ void systemBus::setup()
285249#warning intr_type likely needs to be fixed!
286250#endif
287251
252+ iec_commandQueue = xQueueCreate (10 , sizeof (IECData *));
253+
288254 // Start task
289255 // xTaskCreatePinnedToCore(ml_iec_intr_task, "ml_iec_intr_task", 4096, NULL, 20, NULL, 1);
290256
@@ -301,19 +267,21 @@ void systemBus::setup()
301267
302268 // Setup interrupt config for CLK
303269 io_conf = {
304- .pin_bit_mask = (1ULL << PIN_IEC_CLK_IN), // bit mask of the pins that you want to set
305- .mode = GPIO_MODE_INPUT, // set as input mode
306- .pull_up_en = GPIO_PULLUP_DISABLE, // disable pull-up mode
307- .pull_down_en = GPIO_PULLDOWN_DISABLE, // disable pull-down mode
308- .intr_type = GPIO_INTR_POSEDGE // interrupt of rising edge
270+ .pin_bit_mask = (1ULL << PIN_IEC_CLK_IN), // bit mask of the pins that you want to set
271+ .mode = GPIO_MODE_INPUT, // set as input mode
272+ .pull_up_en = GPIO_PULLUP_DISABLE, // disable pull-up mode
273+ .pull_down_en = GPIO_PULLDOWN_DISABLE, // disable pull-down mode
274+ #ifdef IEC_INVERTED_LINES
275+ .intr_type = GPIO_INTR_NEGEDGE // interrupt of falling edge
276+ #else
277+ .intr_type = GPIO_INTR_POSEDGE // interrupt of rising edge
278+ #endif
309279 };
310280 gpio_config (&io_conf);
311281 gpio_isr_handler_add ((gpio_num_t )PIN_IEC_CLK_IN, cbm_on_clk_isr_forwarder, this );
312282
313- iec_commandQueue = xQueueCreate (10 , sizeof (IECData *));
314-
315283 // Start SRQ timer service
316- timer_start ();
284+ // timer_start_srq ();
317285}
318286
319287void IRAM_ATTR systemBus::service ()
@@ -341,7 +309,7 @@ void IRAM_ATTR systemBus::service()
341309/* *
342310 * Start the Interrupt rate limiting timer
343311 */
344- void systemBus::timer_start ()
312+ void systemBus::timer_start_srq ()
345313{
346314 esp_timer_create_args_t tcfg;
347315 tcfg.arg = this ;
@@ -355,7 +323,7 @@ void systemBus::timer_start()
355323/* *
356324 * Stop the Interrupt rate limiting timer
357325 */
358- void systemBus::timer_stop ()
326+ void systemBus::timer_stop_srq ()
359327{
360328 // Delete existing timer
361329 if (rateTimerHandle != nullptr )
@@ -373,23 +341,28 @@ std::shared_ptr<IECProtocol> systemBus::selectProtocol()
373341
374342 switch (detected_protocol)
375343 {
376- case PROTOCOL_JIFFYDOS: {
377- auto p = std::make_shared<JiffyDOS>();
378- return std::static_pointer_cast<IECProtocol>(p);
379- }
344+ #ifdef JIFFYDOS
345+ case PROTOCOL_JIFFYDOS:
346+ {
347+ auto p = std::make_shared<JiffyDOS>();
348+ return std::static_pointer_cast<IECProtocol>(p);
349+ }
350+ #endif
380351#ifdef PARALLEL_BUS
381- case PROTOCOL_DOLPHINDOS: {
382- auto p = std::make_shared<DolphinDOS>();
383- return std::static_pointer_cast<IECProtocol>(p);
384- }
352+ case PROTOCOL_DOLPHINDOS:
353+ {
354+ auto p = std::make_shared<DolphinDOS>();
355+ return std::static_pointer_cast<IECProtocol>(p);
356+ }
385357#endif
386- default : {
358+ default :
359+ {
387360#ifdef PARALLEL_BUS
388- PARALLEL.state = PBUS_IDLE;
361+ PARALLEL.state = PBUS_IDLE;
389362#endif
390- auto p = std::make_shared<CPBStandardSerial>();
391- return std::static_pointer_cast<IECProtocol>(p);
392- }
363+ auto p = std::make_shared<CPBStandardSerial>();
364+ return std::static_pointer_cast<IECProtocol>(p);
365+ }
393366 }
394367}
395368
@@ -448,7 +421,7 @@ void systemBus::assert_interrupt()
448421 if (interruptSRQ)
449422 IEC_ASSERT (PIN_IEC_SRQ);
450423 else
451- IEC_RELEASE (PIN_DEBUG );
424+ IEC_RELEASE (PIN_IEC_SRQ );
452425}
453426
454427bool systemBus::sendByte (const char c, bool eoi) { return protocol->sendByte (c, eoi); }
@@ -530,19 +503,18 @@ void systemBus::reset_all_our_devices()
530503
531504void systemBus::setBitTiming (std::string set, int p1, int p2, int p3, int p4)
532505{
533- uint8_t i = 0 ; // Send
534- if (mstr::equals (set, (char *)" r" ))
535- i = 1 ;
536- if (p1)
537- protocol->bit_pair_timing [i][0 ] = p1;
538- if (p2)
539- protocol->bit_pair_timing [i][1 ] = p2;
540- if (p3)
541- protocol->bit_pair_timing [i][2 ] = p3;
542- if (p4)
543- protocol->bit_pair_timing [i][3 ] = p4;
544-
545- Debug_printv (" i[%d] timing[%d][%d][%d][%d]" , i, protocol->bit_pair_timing [i][0 ], protocol->bit_pair_timing [i][1 ], protocol->bit_pair_timing [i][2 ], protocol->bit_pair_timing [i][3 ]);
506+ uint8_t i = 0 ; // Send
507+ if (mstr::equals (set, (char *) " r" )) i = 1 ;
508+ if (p1) protocol->bit_pair_timing [i][0 ] = p1;
509+ if (p2) protocol->bit_pair_timing [i][1 ] = p2;
510+ if (p3) protocol->bit_pair_timing [i][2 ] = p3;
511+ if (p4) protocol->bit_pair_timing [i][3 ] = p4;
512+
513+ Debug_printv (" i[%d] timing[%d][%d][%d][%d]" , i,
514+ protocol->bit_pair_timing [i][0 ],
515+ protocol->bit_pair_timing [i][1 ],
516+ protocol->bit_pair_timing [i][2 ],
517+ protocol->bit_pair_timing [i][3 ]);
546518}
547519
548520void IRAM_ATTR systemBus::releaseLines (bool wait)
0 commit comments