Replacement for regular GPIO (DigitalIn, DigitalOut, DigitalInOut) classes which has superior speed.
Fork of FastIO by
Revision 17:87872fcf8586, committed 2015-07-11
- Comitter:
- Sissors
- Date:
- Sat Jul 11 14:38:29 2015 +0000
- Parent:
- 16:a56c0e7ebf7f
- Child:
- 18:c95920122b2e
- Commit message:
- Fixed some of the child class problems, C++ templates are a pain. In general just use FastInOut
Changed in this revision
Devices/FastIO_EFM32.h | Show annotated file Show diff for this revision Revisions of this file |
FastIO_Unsupported.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Devices/FastIO_EFM32.h Sat Jul 11 14:27:43 2015 +0000 +++ b/Devices/FastIO_EFM32.h Sat Jul 11 14:38:29 2015 +0000 @@ -18,16 +18,16 @@ #define MODE_REG (*((&GPIO->P[PORT_INDEX].MODEL) + PIN_INDEX / 8)) #define MODE_SHIFT ((PIN_INDEX * 4) % 32) -#define INIT_PIN container.mask = PINMASK; container.input_mode = PullDefault; container.output_mode = PushPull; CMU_ClockEnable(cmuClock_HFPER, true); CMU_ClockEnable(cmuClock_GPIO, true) +#define INIT_PIN this->container.mask = PINMASK; this->container.input_mode = PullDefault; this->container.output_mode = PushPull; CMU_ClockEnable(cmuClock_HFPER, true); CMU_ClockEnable(cmuClock_GPIO, true) #define DESTROY_PIN -#define SET_DIR_INPUT uint32_t temp = MODE_REG & ~(0xF << MODE_SHIFT); MODE_REG = temp + ((container.input_mode & 0xF) << MODE_SHIFT); if (container.input_mode > 0x10) WRITE_PIN_SET; else WRITE_PIN_CLR +#define SET_DIR_INPUT uint32_t temp = MODE_REG & ~(0xF << MODE_SHIFT); MODE_REG = temp + ((this->container.input_mode & 0xF) << MODE_SHIFT); if (this->container.input_mode > 0x10) WRITE_PIN_SET; else WRITE_PIN_CLR #define SET_DIR_OUTPUT uint32_t temp = MODE_REG & ~(0xF << MODE_SHIFT); MODE_REG = temp + (container.output_mode << MODE_SHIFT) -#define SET_MODE(pull) if ((pull <= 3) || (pull > 0x10)) {container.input_mode = pull; SET_DIR_INPUT; } else {container.output_mode = pull; SET_DIR_OUTPUT;} +#define SET_MODE(pull) if ((pull <= 3) || (pull > 0x10)) {this->container.input_mode = pull; SET_DIR_INPUT; } else {this->container.output_mode = pull; SET_DIR_OUTPUT;} #define WRITE_PIN_SET GPIO->P[PORT_INDEX].DOUTSET = PINMASK #define WRITE_PIN_CLR GPIO->P[PORT_INDEX].DOUTCLR = PINMASK -#define READ_PIN ((GPIO->P[PORT_INDEX].DIN & PINMASK) ? 1 : 0) +#define READ_PIN ((GPIO->P[PORT_INDEX].DIN & this->container.mask) ? 1 : 0) #endif
--- a/FastIO_Unsupported.h Sat Jul 11 14:27:43 2015 +0000 +++ b/FastIO_Unsupported.h Sat Jul 11 14:38:29 2015 +0000 @@ -4,15 +4,15 @@ DigitalInOut *_pin; } fastio_vars; -#define INIT_PIN container._pin = new DigitalInOut(pin) -#define DESTROY_PIN delete(container._pin) +#define INIT_PIN this->container._pin = new DigitalInOut(pin) +#define DESTROY_PIN delete(this->container._pin) -#define SET_DIR_INPUT container._pin->input() -#define SET_DIR_OUTPUT container._pin->output() -#define SET_MODE(pull) container._pin->mode(pull) +#define SET_DIR_INPUT this->container._pin->input() +#define SET_DIR_OUTPUT this->container._pin->output() +#define SET_MODE(pull) this->container._pin->mode(pull) -#define WRITE_PIN_SET container._pin->write(1) -#define WRITE_PIN_CLR container._pin->write(0) +#define WRITE_PIN_SET this->container._pin->write(1) +#define WRITE_PIN_CLR this->container._pin->write(0) -#define READ_PIN container._pin->read() +#define READ_PIN this->container._pin->read()