Compare commits

..

1 Commits

Author SHA1 Message Date
Sam Edwards
ce5761d814
Easier to change LEDs
- For building for boards with different LEDs and configurations
 - Define mode for LED
 - Use gpio_write function to leverage pin definitions
2023-08-10 17:26:48 -07:00
2 changed files with 14 additions and 20 deletions

View File

@ -1936,9 +1936,6 @@ byte onReadBuffer(SCSI_DEVICE *dev, const byte *cdb)
{
byte mode = cdb[1] & 7;
unsigned m_scsi_buf_size = 0;
#if DEBUG > 0
uint32_t allocLength = ((uint32_t)cdb[6] << 16) | ((uint32_t)cdb[7] << 8) | cdb[8];
#endif
LOGN("-ReadBuffer");
LOGHEXN(mode);
@ -1958,6 +1955,7 @@ byte onReadBuffer(SCSI_DEVICE *dev, const byte *cdb)
writeDataPhase(4 + m_scsi_buf_size, m_buf);
#if DEBUG > 0
uint32_t allocLength = ((uint32_t)cdb[6] << 16) | ((uint32_t)cdb[7] << 8) | cdb[8];
for (unsigned i = 0; i < allocLength; i++) {
LOGHEX(m_scsi_buf[i]);LOG(" ");
}

View File

@ -100,6 +100,18 @@ enum SCSI_DEVICE_TYPE
#define SD_CS PA4 // SDCARD:CS
// Built-in LED
#define LED PC13
#define LED_MODE GPIO_OUTPUT_OD
// External LED
#define LED2 PA0
#define LED2_MODE GPIO_OUTPUT_PP
// LED control
#define LED_ON() gpio_write(LED, (LED_MODE == GPIO_OUTPUT_PP) ? low : high); gpio_write(LED2, (LED_MODE == GPIO_OUTPUT_PP) ? low : high);
#define LED_OFF() gpio_write(LED, (LED_MODE == GPIO_OUTPUT_PP) ? high : low); gpio_write(LED2, (LED_MODE == GPIO_OUTPUT_PP) ? high : low);
// Image Set Selector
#ifdef XCVR
#define IMAGE_SELECT1 PC14
@ -117,26 +129,10 @@ enum SCSI_DEVICE_TYPE
// Virtual pin (Arduio compatibility is slow, so make it MCU-dependent)
#define PA(BIT) (BIT)
#define PB(BIT) (BIT+16)
#define PC(BIT) (BIT+32)
// Virtual pin decoding
#define GPIOREG(VPIN) ((VPIN)>=16?((VPIN)>=32?PCREG:PBREG):PAREG)
#define GPIOREG(VPIN) ((VPIN)>=16?PBREG:PAREG)
#define BITMASK(VPIN) (1<<((VPIN)&15))
// Built-in LED
#define LED PC13
#define vLED PC(13)
#define LED_MODE GPIO_OUTPUT_OD
// External LED
#define LED2 PA0
#define vLED2 PA(0)
#define LED2_MODE GPIO_OUTPUT_PP
// LED control
#define LED_ON() GPIOREG(vLED)->BSRR = BITMASK(vLED) << (LED_MODE == GPIO_OUTPUT_PP ? 0 : 16); GPIOREG(vLED2)->BSRR = BITMASK(vLED2) << (LED2_MODE == GPIO_OUTPUT_PP ? 0 : 16);
#define LED_OFF() GPIOREG(vLED)->BSRR = BITMASK(vLED) << (LED_MODE == GPIO_OUTPUT_PP ? 16 : 0); GPIOREG(vLED2)->BSRR = BITMASK(vLED2) << (LED2_MODE == GPIO_OUTPUT_PP ? 16 : 0);
#define vATN PA(8) // SCSI:ATN
#define vBSY PA(9) // SCSI:BSY
#define vACK PA(10) // SCSI:ACK