diff options
| author | Joel Challis <git@zvecr.com> | 2021-10-20 21:18:49 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-20 21:18:49 +0100 |
| commit | d4be4b67a251ecc046d857c5cd00cfb37c394ab7 (patch) | |
| tree | 15f6dd05ec293081782a9b42a30e1a81b33b6aa0 /platforms/chibios | |
| parent | 5500c428dd41348243e8a1695986b0da070e2ffa (diff) | |
| download | qmk_firmware-d4be4b67a251ecc046d857c5cd00cfb37c394ab7.tar.gz qmk_firmware-d4be4b67a251ecc046d857c5cd00cfb37c394ab7.zip | |
Relocate PS2 code (#14895)
* Relocate ps2 protocol code
* clang
* Move makefile logic
Diffstat (limited to 'platforms/chibios')
| -rw-r--r-- | platforms/chibios/drivers/ps2/ps2_io.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/platforms/chibios/drivers/ps2/ps2_io.c b/platforms/chibios/drivers/ps2/ps2_io.c new file mode 100644 index 000000000..906d85d84 --- /dev/null +++ b/platforms/chibios/drivers/ps2/ps2_io.c | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | #include <stdbool.h> | ||
| 2 | #include "ps2_io.h" | ||
| 3 | |||
| 4 | // chibiOS headers | ||
| 5 | #include "ch.h" | ||
| 6 | #include "hal.h" | ||
| 7 | |||
| 8 | /* Check port settings for clock and data line */ | ||
| 9 | #if !(defined(PS2_CLOCK_PIN)) | ||
| 10 | # error "PS/2 clock setting is required in config.h" | ||
| 11 | #endif | ||
| 12 | |||
| 13 | #if !(defined(PS2_DATA_PIN)) | ||
| 14 | # error "PS/2 data setting is required in config.h" | ||
| 15 | #endif | ||
| 16 | |||
| 17 | /* | ||
| 18 | * Clock | ||
| 19 | */ | ||
| 20 | void clock_init(void) {} | ||
| 21 | |||
| 22 | void clock_lo(void) { | ||
| 23 | palSetLineMode(PS2_CLOCK_PIN, PAL_MODE_OUTPUT_OPENDRAIN); | ||
| 24 | palWriteLine(PS2_CLOCK_PIN, PAL_LOW); | ||
| 25 | } | ||
| 26 | |||
| 27 | void clock_hi(void) { | ||
| 28 | palSetLineMode(PS2_CLOCK_PIN, PAL_MODE_OUTPUT_OPENDRAIN); | ||
| 29 | palWriteLine(PS2_CLOCK_PIN, PAL_HIGH); | ||
| 30 | } | ||
| 31 | |||
| 32 | bool clock_in(void) { | ||
| 33 | palSetLineMode(PS2_CLOCK_PIN, PAL_MODE_INPUT); | ||
| 34 | return palReadLine(PS2_CLOCK_PIN); | ||
| 35 | } | ||
| 36 | |||
| 37 | /* | ||
| 38 | * Data | ||
| 39 | */ | ||
| 40 | void data_init(void) {} | ||
| 41 | |||
| 42 | void data_lo(void) { | ||
| 43 | palSetLineMode(PS2_DATA_PIN, PAL_MODE_OUTPUT_OPENDRAIN); | ||
| 44 | palWriteLine(PS2_DATA_PIN, PAL_LOW); | ||
| 45 | } | ||
| 46 | |||
| 47 | void data_hi(void) { | ||
| 48 | palSetLineMode(PS2_DATA_PIN, PAL_MODE_OUTPUT_OPENDRAIN); | ||
| 49 | palWriteLine(PS2_DATA_PIN, PAL_HIGH); | ||
| 50 | } | ||
| 51 | |||
| 52 | bool data_in(void) { | ||
| 53 | palSetLineMode(PS2_DATA_PIN, PAL_MODE_INPUT); | ||
| 54 | return palReadLine(PS2_DATA_PIN); | ||
| 55 | } | ||
