mirror of
https://github.com/keirf/greaseweazle-firmware.git
synced 2025-10-31 11:06:44 -07:00
New firmware command CMD_GET_PIN to read an interface pin's voltage level.
This commit is contained in:
@@ -67,7 +67,10 @@
|
||||
#define CMD_SOURCE_BYTES 18
|
||||
/* CMD_SINK_BYTES, length=6. Argument is gw_sink_source_bytes. */
|
||||
#define CMD_SINK_BYTES 19
|
||||
#define CMD_MAX 19
|
||||
/* CMD_GET_PIN, length=3, pin#. Successful ACK is followed by pin-level byte
|
||||
* (1=High, 0=Low). Unsupported pin returns ACK_BAD_PIN and no pin level. */
|
||||
#define CMD_GET_PIN 20
|
||||
#define CMD_MAX 20
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -173,6 +173,11 @@ static uint8_t drive_motor(uint8_t nr, bool_t on)
|
||||
return ACK_OKAY;
|
||||
}
|
||||
|
||||
static uint8_t mcu_get_floppy_pin(unsigned int pin, uint8_t *p_level)
|
||||
{
|
||||
return ACK_BAD_PIN;
|
||||
}
|
||||
|
||||
static uint8_t set_user_pin(unsigned int pin, unsigned int level)
|
||||
{
|
||||
if (pin != 2)
|
||||
|
||||
@@ -265,6 +265,20 @@ static uint8_t drive_motor(uint8_t nr, bool_t on)
|
||||
|
||||
}
|
||||
|
||||
static uint8_t mcu_get_floppy_pin(unsigned int pin, uint8_t *p_level)
|
||||
{
|
||||
switch (gw_info.hw_submodel) {
|
||||
case F7SM_v3:
|
||||
case F7SM_lightning_plus:
|
||||
if (pin == 34) {
|
||||
*p_level = gpio_read_pin(gpioc, 2);
|
||||
return ACK_OKAY;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return ACK_BAD_PIN;
|
||||
}
|
||||
|
||||
static uint8_t set_user_pin(unsigned int pin, unsigned int level)
|
||||
{
|
||||
const struct pin_mapping *upin;
|
||||
|
||||
29
src/floppy.c
29
src/floppy.c
@@ -296,6 +296,26 @@ static bool_t set_bus_type(uint8_t type)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static uint8_t get_floppy_pin(unsigned int pin, uint8_t *p_level)
|
||||
{
|
||||
uint8_t rc = ACK_OKAY;
|
||||
switch (pin) {
|
||||
case 8:
|
||||
*p_level = get_index();
|
||||
break;
|
||||
case 26:
|
||||
*p_level = get_trk0();
|
||||
break;
|
||||
case 28:
|
||||
*p_level = get_wrprot();
|
||||
break;
|
||||
default:
|
||||
rc = mcu_get_floppy_pin(pin, p_level);
|
||||
break;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void floppy_reset(void)
|
||||
{
|
||||
floppy_state = ST_inactive;
|
||||
@@ -1262,6 +1282,15 @@ static void process_command(void)
|
||||
u_buf[1] = set_user_pin(pin, level);
|
||||
goto out;
|
||||
}
|
||||
case CMD_GET_PIN: {
|
||||
uint8_t pin = u_buf[2];
|
||||
if (len != 3)
|
||||
goto bad_command;
|
||||
u_buf[1] = get_floppy_pin(pin, &u_buf[2]);
|
||||
if (u_buf[1] == ACK_OKAY)
|
||||
resp_sz += 1;
|
||||
goto out;
|
||||
}
|
||||
case CMD_RESET: {
|
||||
if (len != 2)
|
||||
goto bad_command;
|
||||
|
||||
Reference in New Issue
Block a user