| 56 | } |
| 57 | |
| 58 | inline void pinMode(int pin, PinMode mode) FL_NOEXCEPT { |
| 59 | u32 mask; |
| 60 | Pio* pio = detail::getPioController(pin, mask); |
| 61 | if (!pio) return; |
| 62 | |
| 63 | // Enable PIO control of the pin |
| 64 | pio->PIO_PER = mask; |
| 65 | |
| 66 | switch (mode) { |
| 67 | case PinMode::Output: |
| 68 | pio->PIO_OER = mask; // Enable output |
| 69 | pio->PIO_PUDR = mask; // Disable pull-up |
| 70 | break; |
| 71 | case PinMode::Input: |
| 72 | pio->PIO_ODR = mask; // Disable output (input mode) |
| 73 | pio->PIO_PUDR = mask; // Disable pull-up |
| 74 | break; |
| 75 | case PinMode::InputPullup: |
| 76 | pio->PIO_ODR = mask; // Disable output (input mode) |
| 77 | pio->PIO_PUER = mask; // Enable pull-up |
| 78 | break; |
| 79 | case PinMode::InputPulldown: |
| 80 | // SAM3X8E does not support internal pull-down resistors |
| 81 | // Fall back to standard input mode |
| 82 | pio->PIO_ODR = mask; // Disable output (input mode) |
| 83 | pio->PIO_PUDR = mask; // Disable pull-up |
| 84 | break; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | inline void digitalWrite(int pin, PinValue val) FL_NOEXCEPT { |
| 89 | u32 mask; |