Skip to content

Commit 901eaa1

Browse files
committed
Define more SmartPort command constants.
1 parent 85e4e1e commit 901eaa1

File tree

4 files changed

+65
-50
lines changed

4 files changed

+65
-50
lines changed

lib/bus/iwm/iwm.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,16 @@ 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_ECMD_UNKNOWN1:
264+
case SP_ECMD_UNKNOWN2:
265+
case SP_CMD_WRITEBLOCK:
266+
case SP_CMD_CONTROL:
267+
case SP_CMD_WRITE:
268+
case SP_CMD_UNKNOWN1:
269+
case SP_CMD_UNKNOWN2:
270270
data_len = 512;
271271
IWM.iwm_decode_data_packet((uint8_t *)data_buffer, data_len);
272272
Debug_printf("\r\nUnit %02x Bad Command with data packet %02x\r\n", id(), cmd.command);
@@ -278,7 +278,7 @@ void iwmDevice::iwm_return_badcmd(iwm_decoded_cmd_t cmd)
278278
return;
279279
}
280280

281-
if(cmd.command == 0x04) //Decode command control code
281+
if(cmd.command == SP_CMD_CONTROL) //Decode command control code
282282
{
283283
send_reply_packet(SP_ERR_BADCTL); //we may be required to accept some control commands
284284
// but for now just report bad control if it's a control
@@ -297,16 +297,16 @@ void iwmDevice::iwm_return_device_offline(iwm_decoded_cmd_t cmd)
297297
//Handle possible data packet to avoid crash extended and non-extended
298298
switch(cmd.command)
299299
{
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:
300+
case SP_ECMD_WRITEBLOCK:
301+
case SP_ECMD_CONTROL:
302+
case SP_ECMD_WRITE:
303+
case SP_ECMD_UNKNOWN1:
304+
case SP_ECMD_UNKNOWN2:
305+
case SP_CMD_WRITEBLOCK:
306+
case SP_CMD_CONTROL:
307+
case SP_CMD_WRITE:
308+
case SP_CMD_UNKNOWN1:
309+
case SP_CMD_UNKNOWN2:
310310
data_len = 512;
311311
IWM.iwm_decode_data_packet((uint8_t *)data_buffer, data_len);
312312
Debug_printf("\r\nUnit %02x Offline, Command with data packet %02x\r\n", id(), cmd.command);
@@ -318,7 +318,7 @@ void iwmDevice::iwm_return_device_offline(iwm_decoded_cmd_t cmd)
318318
return;
319319
}
320320

321-
if(cmd.command == 0x04) //Decode command control code
321+
if(cmd.command == SP_CMD_CONTROL) //Decode command control code
322322
{
323323
send_reply_packet(SP_ERR_OFFLINE);
324324
uint8_t control_code = get_status_code(cmd);
@@ -345,7 +345,7 @@ void iwmDevice::iwm_status(iwm_decoded_cmd_t cmd) // override;
345345
{
346346
uint8_t status_code = cmd.params[2];
347347

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

lib/bus/iwm/iwm.h

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,30 @@
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_CMD_UNKNOWN1 = 0x0a,
36+
SP_CMD_UNKNOWN2 = 0x0b,
37+
SP_ECMD_STATUS = 0x40,
38+
SP_ECMD_READBLOCK = 0x41,
39+
SP_ECMD_WRITEBLOCK = 0x42,
40+
SP_ECMD_FORMAT = 0x43,
41+
SP_ECMD_CONTROL = 0x44,
42+
SP_ECMD_INIT = 0x45,
43+
SP_ECMD_OPEN = 0x46,
44+
SP_ECMD_CLOSE = 0x47,
45+
SP_ECMD_READ = 0x48,
46+
SP_ECMD_WRITE = 0x49,
47+
SP_ECMD_UNKNOWN1 = 0x4a,
48+
SP_ECMD_UNKNOWN2 = 0x4b,
3449
};
3550

3651
// 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: 6 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,11 @@ 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) ||
79+
(c == SP_CMD_UNKNOWN1) ||
80+
(c == SP_CMD_UNKNOWN2))
8181
{
8282
// Debug_printf("\nhello from ISR - control command!");
8383
if (smartport.req_wait_for_falling_timeout(5500))

lib/bus/mac/mac.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -528,16 +528,16 @@ 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_ECMD_UNKNOWN1:
535+
case SP_ECMD_UNKNOWN2:
536+
case SP_CMD_WRITEBLOCK:
537+
case SP_CMD_CONTROL:
538+
case SP_CMD_WRITE:
539+
case SP_CMD_UNKNOWN1:
540+
case SP_CMD_UNKNOWN2:
541541
data_len = 512;
542542
IWM.iwm_decode_data_packet((uint8_t *)data_buffer, data_len);
543543
Debug_printf("\r\nUnit %02x Bad Command with data packet %02x\r\n", id(), cmd.command);
@@ -548,7 +548,7 @@ void iwmDevice::iwm_return_badcmd(iwm_decoded_cmd_t cmd)
548548
Debug_printf("\r\nUnit %02x Bad Command %02x", id(), cmd.command);
549549
return;
550550
}
551-
if (cmd.command == 0x04) // Decode command control code
551+
if (cmd.command == SP_CMD_CONTROL) // Decode command control code
552552
{
553553
send_reply_packet(SP_ERR_BADCTL); // we may be required to accept some control commands
554554
// but for now just report bad control if it's a control
@@ -578,7 +578,7 @@ void iwmDevice::iwm_status(iwm_decoded_cmd_t cmd) // override;
578578
uint8_t status_code = cmd.params[2]; // cmd.g7byte3 & 0x7f; // (packet_buffer[19] & 0x7f); // | (((unsigned short)packet_buffer[16] << 3) & 0x80);
579579
Debug_printf("\r\nTarget Device: %02x", id());
580580
// add a switch case statement for ALL THE STATUSESESESESS
581-
if (status_code == 0x03)
581+
if (status_code == SP_CMD_FORMAT)
582582
{ // if statcode=3, then status with device info block
583583
Debug_printf("\r\n******** Sending DIB! ********");
584584
send_status_dib_reply_packet();

0 commit comments

Comments
 (0)