Skip to content

Commit a82efd1

Browse files
FozzTexxtschak909
authored andcommitted
Define more SmartPort command constants.
1 parent 85e4e1e commit a82efd1

File tree

4 files changed

+47
-50
lines changed

4 files changed

+47
-50
lines changed

lib/bus/iwm/iwm.cpp

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,12 @@ void iwmDevice::iwm_return_badcmd(iwm_decoded_cmd_t cmd)
257257
//Handle possible data packet to avoid crash extended and non-extended
258258
switch(cmd.command)
259259
{
260-
case 0x42:
261-
case 0x44:
262-
case 0x49:
263-
case 0x4a:
264-
case 0x4b:
265-
case 0x02:
266-
case 0x04:
267-
case 0x09:
268-
case 0x0a:
269-
case 0x0b:
260+
case SP_ECMD_WRITEBLOCK:
261+
case SP_ECMD_CONTROL:
262+
case SP_ECMD_WRITE:
263+
case SP_CMD_WRITEBLOCK:
264+
case SP_CMD_CONTROL:
265+
case SP_CMD_WRITE:
270266
data_len = 512;
271267
IWM.iwm_decode_data_packet((uint8_t *)data_buffer, data_len);
272268
Debug_printf("\r\nUnit %02x Bad Command with data packet %02x\r\n", id(), cmd.command);
@@ -278,7 +274,7 @@ void iwmDevice::iwm_return_badcmd(iwm_decoded_cmd_t cmd)
278274
return;
279275
}
280276

281-
if(cmd.command == 0x04) //Decode command control code
277+
if(cmd.command == SP_CMD_CONTROL) //Decode command control code
282278
{
283279
send_reply_packet(SP_ERR_BADCTL); //we may be required to accept some control commands
284280
// but for now just report bad control if it's a control
@@ -297,16 +293,12 @@ void iwmDevice::iwm_return_device_offline(iwm_decoded_cmd_t cmd)
297293
//Handle possible data packet to avoid crash extended and non-extended
298294
switch(cmd.command)
299295
{
300-
case 0x42:
301-
case 0x44:
302-
case 0x49:
303-
case 0x4a:
304-
case 0x4b:
305-
case 0x02:
306-
case 0x04:
307-
case 0x09:
308-
case 0x0a:
309-
case 0x0b:
296+
case SP_ECMD_WRITEBLOCK:
297+
case SP_ECMD_CONTROL:
298+
case SP_ECMD_WRITE:
299+
case SP_CMD_WRITEBLOCK:
300+
case SP_CMD_CONTROL:
301+
case SP_CMD_WRITE:
310302
data_len = 512;
311303
IWM.iwm_decode_data_packet((uint8_t *)data_buffer, data_len);
312304
Debug_printf("\r\nUnit %02x Offline, Command with data packet %02x\r\n", id(), cmd.command);
@@ -318,7 +310,7 @@ void iwmDevice::iwm_return_device_offline(iwm_decoded_cmd_t cmd)
318310
return;
319311
}
320312

321-
if(cmd.command == 0x04) //Decode command control code
313+
if(cmd.command == SP_CMD_CONTROL) //Decode command control code
322314
{
323315
send_reply_packet(SP_ERR_OFFLINE);
324316
uint8_t control_code = get_status_code(cmd);
@@ -345,7 +337,7 @@ void iwmDevice::iwm_status(iwm_decoded_cmd_t cmd) // override;
345337
{
346338
uint8_t status_code = cmd.params[2];
347339

348-
if (status_code == 0x03)
340+
if (status_code == SP_CMD_FORMAT)
349341
{
350342
Debug_printf("\r\nSending DIB Status for device 0x%02x", id());
351343
send_status_dib_reply_packet();

lib/bus/iwm/iwm.h

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,26 @@
2222
#include "fnFS.h"
2323

2424
enum {
25-
SP_CMD_STATUS = 0x00,
26-
SP_CMD_READBLOCK = 0x01,
27-
SP_CMD_WRITEBLOCK = 0x02,
28-
SP_CMD_FORMAT = 0x03,
29-
SP_CMD_CONTROL = 0x04,
30-
SP_CMD_OPEN = 0x06,
31-
SP_CMD_CLOSE = 0x07,
32-
SP_CMD_READ = 0x08,
33-
SP_CMD_WRITE = 0x09,
25+
SP_CMD_STATUS = 0x00,
26+
SP_CMD_READBLOCK = 0x01,
27+
SP_CMD_WRITEBLOCK = 0x02,
28+
SP_CMD_FORMAT = 0x03,
29+
SP_CMD_CONTROL = 0x04,
30+
SP_CMD_INIT = 0x05,
31+
SP_CMD_OPEN = 0x06,
32+
SP_CMD_CLOSE = 0x07,
33+
SP_CMD_READ = 0x08,
34+
SP_CMD_WRITE = 0x09,
35+
SP_ECMD_STATUS = 0x40,
36+
SP_ECMD_READBLOCK = 0x41,
37+
SP_ECMD_WRITEBLOCK = 0x42,
38+
SP_ECMD_FORMAT = 0x43,
39+
SP_ECMD_CONTROL = 0x44,
40+
SP_ECMD_INIT = 0x45,
41+
SP_ECMD_OPEN = 0x46,
42+
SP_ECMD_CLOSE = 0x47,
43+
SP_ECMD_READ = 0x48,
44+
SP_ECMD_WRITE = 0x49,
3445
};
3546

3647
// see page 81-82 in Apple IIc ROM reference and Table 7-5 in IIgs firmware ref

lib/bus/iwm/iwm_ll.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void IRAM_ATTR phi_isr_handler(void *arg)
5858
c = IWM.command_packet.command & 0x0f;
5959
if (!error) // packet received ok and checksum good
6060
{
61-
if (c == 0x05)
61+
if (c == SP_CMD_INIT)
6262
{
6363
smartport.iwm_ack_clr();
6464
sp_command_mode = sp_cmd_state_t::command;
@@ -73,11 +73,9 @@ void IRAM_ATTR phi_isr_handler(void *arg)
7373
// look for CTRL command
7474
// Debug_printf("\nhello from ISR - looking for control command!");
7575

76-
if ((c == 0x02) ||
77-
(c == 0x04) ||
78-
(c == 0x09) ||
79-
(c == 0x0a) ||
80-
(c == 0x0b))
76+
if ((c == SP_CMD_WRITEBLOCK) ||
77+
(c == SP_CMD_CONTROL) ||
78+
(c == SP_CMD_WRITE))
8179
{
8280
// Debug_printf("\nhello from ISR - control command!");
8381
if (smartport.req_wait_for_falling_timeout(5500))

lib/bus/mac/mac.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -528,16 +528,12 @@ void iwmDevice::iwm_return_badcmd(iwm_decoded_cmd_t cmd)
528528
// Handle possible data packet to avoid crash extended and non-extended
529529
switch (cmd.command)
530530
{
531-
case 0x42:
532-
case 0x44:
533-
case 0x49:
534-
case 0x4a:
535-
case 0x4b:
536-
case 0x02:
537-
case 0x04:
538-
case 0x09:
539-
case 0x0a:
540-
case 0x0b:
531+
case SP_ECMD_WRITEBLOCK:
532+
case SP_ECMD_CONTROL:
533+
case SP_ECMD_WRITE:
534+
case SP_CMD_WRITEBLOCK:
535+
case SP_CMD_CONTROL:
536+
case SP_CMD_WRITE:
541537
data_len = 512;
542538
IWM.iwm_decode_data_packet((uint8_t *)data_buffer, data_len);
543539
Debug_printf("\r\nUnit %02x Bad Command with data packet %02x\r\n", id(), cmd.command);
@@ -548,7 +544,7 @@ void iwmDevice::iwm_return_badcmd(iwm_decoded_cmd_t cmd)
548544
Debug_printf("\r\nUnit %02x Bad Command %02x", id(), cmd.command);
549545
return;
550546
}
551-
if (cmd.command == 0x04) // Decode command control code
547+
if (cmd.command == SP_CMD_CONTROL) // Decode command control code
552548
{
553549
send_reply_packet(SP_ERR_BADCTL); // we may be required to accept some control commands
554550
// but for now just report bad control if it's a control
@@ -578,7 +574,7 @@ void iwmDevice::iwm_status(iwm_decoded_cmd_t cmd) // override;
578574
uint8_t status_code = cmd.params[2]; // cmd.g7byte3 & 0x7f; // (packet_buffer[19] & 0x7f); // | (((unsigned short)packet_buffer[16] << 3) & 0x80);
579575
Debug_printf("\r\nTarget Device: %02x", id());
580576
// add a switch case statement for ALL THE STATUSESESESESS
581-
if (status_code == 0x03)
577+
if (status_code == SP_CMD_FORMAT)
582578
{ // if statcode=3, then status with device info block
583579
Debug_printf("\r\n******** Sending DIB! ********");
584580
send_status_dib_reply_packet();

0 commit comments

Comments
 (0)