Align PS/2 GPIO defines (#14745)
* Align PS/2 GPIO * Align PS/2 GPIO * refactor more keyboards * Remove more defines * Put back avr/chibios split * format
This commit is contained in:
parent
1fb2a0c74e
commit
84d5198ef9
12 changed files with 94 additions and 192 deletions
|
|
@ -1,14 +1,15 @@
|
|||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include "ps2_io.h"
|
||||
#include "gpio.h"
|
||||
#include "wait.h"
|
||||
|
||||
/* Check port settings for clock and data line */
|
||||
#if !(defined(PS2_CLOCK_PORT) && defined(PS2_CLOCK_PIN) && defined(PS2_CLOCK_DDR) && defined(PS2_CLOCK_BIT))
|
||||
# error "PS/2 clock port setting is required in config.h"
|
||||
#if !(defined(PS2_CLOCK_PIN))
|
||||
# error "PS/2 clock setting is required in config.h"
|
||||
#endif
|
||||
|
||||
#if !(defined(PS2_DATA_PORT) && defined(PS2_DATA_PIN) && defined(PS2_DATA_DDR) && defined(PS2_DATA_BIT))
|
||||
# error "PS/2 data port setting is required in config.h"
|
||||
#if !(defined(PS2_DATA_PIN))
|
||||
# error "PS/2 data setting is required in config.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -17,21 +18,17 @@
|
|||
void clock_init(void) {}
|
||||
|
||||
void clock_lo(void) {
|
||||
PS2_CLOCK_PORT &= ~(1 << PS2_CLOCK_BIT);
|
||||
PS2_CLOCK_DDR |= (1 << PS2_CLOCK_BIT);
|
||||
// Transition from input with pull-up to output low via Hi-Z instead of output high
|
||||
writePinLow(PS2_CLOCK_PIN);
|
||||
setPinOutput(PS2_CLOCK_PIN);
|
||||
}
|
||||
|
||||
void clock_hi(void) {
|
||||
/* input with pull up */
|
||||
PS2_CLOCK_DDR &= ~(1 << PS2_CLOCK_BIT);
|
||||
PS2_CLOCK_PORT |= (1 << PS2_CLOCK_BIT);
|
||||
}
|
||||
void clock_hi(void) { setPinInputHigh(PS2_CLOCK_PIN); }
|
||||
|
||||
bool clock_in(void) {
|
||||
PS2_CLOCK_DDR &= ~(1 << PS2_CLOCK_BIT);
|
||||
PS2_CLOCK_PORT |= (1 << PS2_CLOCK_BIT);
|
||||
_delay_us(1);
|
||||
return PS2_CLOCK_PIN & (1 << PS2_CLOCK_BIT);
|
||||
setPinInputHigh(PS2_CLOCK_PIN);
|
||||
wait_us(1);
|
||||
return readPin(PS2_CLOCK_PIN);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -40,19 +37,15 @@ bool clock_in(void) {
|
|||
void data_init(void) {}
|
||||
|
||||
void data_lo(void) {
|
||||
PS2_DATA_PORT &= ~(1 << PS2_DATA_BIT);
|
||||
PS2_DATA_DDR |= (1 << PS2_DATA_BIT);
|
||||
// Transition from input with pull-up to output low via Hi-Z instead of output high
|
||||
writePinLow(PS2_DATA_PIN);
|
||||
setPinOutput(PS2_DATA_PIN);
|
||||
}
|
||||
|
||||
void data_hi(void) {
|
||||
/* input with pull up */
|
||||
PS2_DATA_DDR &= ~(1 << PS2_DATA_BIT);
|
||||
PS2_DATA_PORT |= (1 << PS2_DATA_BIT);
|
||||
}
|
||||
void data_hi(void) { setPinInputHigh(PS2_DATA_PIN); }
|
||||
|
||||
bool data_in(void) {
|
||||
PS2_DATA_DDR &= ~(1 << PS2_DATA_BIT);
|
||||
PS2_DATA_PORT |= (1 << PS2_DATA_BIT);
|
||||
_delay_us(1);
|
||||
return PS2_DATA_PIN & (1 << PS2_DATA_BIT);
|
||||
setPinInputHigh(PS2_DATA_PIN);
|
||||
wait_us(1);
|
||||
return readPin(PS2_DATA_PIN);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue