mirror of
https://github.com/erichelgeson/BlueSCSI.git
synced 2025-01-03 00:31:26 +00:00
Easier to change LEDs
- For building for boards with different LEDs and configurations - Define mode for LED - Update GPIO macros for port C - Use macros to generate bits for registers
This commit is contained in:
parent
59c858332a
commit
47179c5fd0
@ -442,8 +442,8 @@ void setup()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// PIN initialization
|
// PIN initialization
|
||||||
gpio_mode(LED2, GPIO_OUTPUT_PP);
|
gpio_mode(LED2, LED2_MODE);
|
||||||
gpio_mode(LED, GPIO_OUTPUT_OD);
|
gpio_mode(LED, LED_MODE);
|
||||||
|
|
||||||
// Image Set Select Init
|
// Image Set Select Init
|
||||||
gpio_mode(IMAGE_SELECT1, GPIO_INPUT_PU);
|
gpio_mode(IMAGE_SELECT1, GPIO_INPUT_PU);
|
||||||
|
@ -99,8 +99,6 @@ enum SCSI_DEVICE_TYPE
|
|||||||
#define IO PB7 // SCSI:I/O
|
#define IO PB7 // SCSI:I/O
|
||||||
|
|
||||||
#define SD_CS PA4 // SDCARD:CS
|
#define SD_CS PA4 // SDCARD:CS
|
||||||
#define LED PC13 // LED
|
|
||||||
#define LED2 PA0 // External LED
|
|
||||||
|
|
||||||
// Image Set Selector
|
// Image Set Selector
|
||||||
#ifdef XCVR
|
#ifdef XCVR
|
||||||
@ -116,17 +114,29 @@ enum SCSI_DEVICE_TYPE
|
|||||||
#define PBREG GPIOB->regs
|
#define PBREG GPIOB->regs
|
||||||
#define PCREG GPIOC->regs
|
#define PCREG GPIOC->regs
|
||||||
|
|
||||||
// LED control
|
|
||||||
#define LED_ON() PCREG->BSRR = 0b00100000000000000000000000000000; PAREG->BSRR = 0b00000000000000000000000000000001;
|
|
||||||
#define LED_OFF() PCREG->BSRR = 0b00000000000000000010000000000000; PAREG->BSRR = 0b00000000000000010000000000000000;
|
|
||||||
|
|
||||||
// Virtual pin (Arduio compatibility is slow, so make it MCU-dependent)
|
// Virtual pin (Arduio compatibility is slow, so make it MCU-dependent)
|
||||||
#define PA(BIT) (BIT)
|
#define PA(BIT) (BIT)
|
||||||
#define PB(BIT) (BIT+16)
|
#define PB(BIT) (BIT+16)
|
||||||
|
#define PC(BIT) (BIT+32)
|
||||||
|
|
||||||
// Virtual pin decoding
|
// Virtual pin decoding
|
||||||
#define GPIOREG(VPIN) ((VPIN)>=16?PBREG:PAREG)
|
#define GPIOREG(VPIN) ((VPIN)>=16?((VPIN)>=32?PCREG:PBREG):PAREG)
|
||||||
#define BITMASK(VPIN) (1<<((VPIN)&15))
|
#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 vATN PA(8) // SCSI:ATN
|
||||||
#define vBSY PA(9) // SCSI:BSY
|
#define vBSY PA(9) // SCSI:BSY
|
||||||
#define vACK PA(10) // SCSI:ACK
|
#define vACK PA(10) // SCSI:ACK
|
||||||
|
Loading…
Reference in New Issue
Block a user