int hcs12_configgpio(uint16_t cfgset) { /* Get the port index and pin number */ uint8_t portndx = HCS12_PORTNDX(cfgset); uint8_t pin = HCS12_PIN(cfgset); /* Configure the pin */ if (HCS12_PIMPORT(cfgset)) { pim_configgpio(cfgset, portndx, pin); } else { mebi_configgpio(cfgset, portndx, pin); } /* If the pin is an output, then set the initial value of the output */ if (HCS12_OUTPUT(cfgset)) { hcs12_gpiowrite(cfgset, (cfgset & GPIO_OUTPUT_VALUE) == GPIO_OUTPUT_HIGH); } return OK; }
bool hcs12_gpioread(uint16_t pinset) { uint8_t portndx = HCS12_PORTNDX(pinset); uint8_t pin = HCS12_PIN(pinset); if (HCS12_PIMPORT(pinset)) { return pim_gpioread(portndx, pin); } else { return mebi_gpioread(portndx, pin); } }
void hcs12_gpiowrite(uint16_t pinset, bool value) { uint8_t portndx = HCS12_PORTNDX(pinset); uint8_t pin = HCS12_PIN(pinset); irqstate_t flags = enter_critical_section(); DEBUGASSERT((pinset & GPIO_DIRECTION) == GPIO_OUTPUT); if (HCS12_PIMPORT(pinset)) { pim_gpiowrite(portndx, pin, value); } else { mebi_gpiowrite(portndx, pin, value); } leave_critical_section(flags); }
int hcs12_dumpgpio(uint16_t pinset, const char *msg) { uint8_t portndx = HCS12_PORTNDX(pinset); irqstate_t flags = enter_critical_section(); gpioinfo("pinset: %08x -- %s\n", pinset, msg); if (HCS12_PIMPORT(pinset)) { hcs12_pimdump(portndx); } else { hcs12_mebidump(portndx); } leave_critical_section(flags); return OK; }
int hcs12_dumpgpio(uint16_t pinset, const char *msg) { uint8_t portndx = HCS12_PORTNDX(pinset); irqstate_t flags = irqsave(); lldbg("pinset: %08x -- %s\n", pinset, msg); if (HCS12_PIMPORT(pinset)) { hcs12_pimdump(portndx); } else { hcs12_mebidump(portndx); } irqrestore(flags); return OK; }