QMK-ify some GPIO macros (#8315)
This commit is contained in:
		
							parent
							
								
									37a4b53c4f
								
							
						
					
					
						commit
						16a15c1cfc
					
				
					 12 changed files with 34 additions and 94 deletions
				
			
		| 
						 | 
				
			
			@ -20,7 +20,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		|||
#include QMK_KEYBOARD_H
 | 
			
		||||
#include "protocol/serial.h"
 | 
			
		||||
#include "timer.h"
 | 
			
		||||
#include "pincontrol.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
| 
						 | 
				
			
			@ -96,27 +95,27 @@ void pins_init(void) {
 | 
			
		|||
 // set pins for pullups, Rts , power &etc. 
 | 
			
		||||
 | 
			
		||||
    //print ("pins setup\n");
 | 
			
		||||
    pinMode(VCC_PIN, PinDirectionOutput);
 | 
			
		||||
    digitalWrite(VCC_PIN, PinLevelLow);
 | 
			
		||||
    setPinOutput(VCC_PIN);
 | 
			
		||||
    writePinLow(VCC_PIN);
 | 
			
		||||
 | 
			
		||||
#if ( HANDSPRING == 0)
 | 
			
		||||
 | 
			
		||||
#ifdef CY835
 | 
			
		||||
    pinMode(GND_PIN, PinDirectionOutput);
 | 
			
		||||
    digitalWrite(GND_PIN, PinLevelLow);
 | 
			
		||||
    setPinOutput(GND_PIN);
 | 
			
		||||
    writePinLow(GND_PIN);
 | 
			
		||||
 | 
			
		||||
    pinMode(PULLDOWN_PIN, PinDirectionOutput);
 | 
			
		||||
    digitalWrite(PULLDOWN_PIN, PinLevelLow);
 | 
			
		||||
    setPinOutput(PULLDOWN_PIN);
 | 
			
		||||
    writePinLow(PULLDOWN_PIN);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    pinMode(DCD_PIN, PinDirectionInput);
 | 
			
		||||
    pinMode(RTS_PIN, PinDirectionInput); 
 | 
			
		||||
    setPinInput(DCD_PIN);
 | 
			
		||||
    setPinInput(RTS_PIN);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* check that the other side isn't powered up. 
 | 
			
		||||
    test=digitalRead(DCD_PIN);
 | 
			
		||||
    test=readPin(DCD_PIN);
 | 
			
		||||
    xprintf("b%02X:", test);
 | 
			
		||||
    test=digitalRead(RTS_PIN);
 | 
			
		||||
    test=readPin(RTS_PIN);
 | 
			
		||||
    xprintf("%02X\n", test);
 | 
			
		||||
*/
 | 
			
		||||
 
 | 
			
		||||
| 
						 | 
				
			
			@ -129,20 +128,20 @@ uint8_t rts_reset(void) {
 | 
			
		|||
// On boot, we keep rts as input, then switch roles here
 | 
			
		||||
// on leaving sleep, we toggle the same way
 | 
			
		||||
 | 
			
		||||
    firstread=digitalRead(RTS_PIN);
 | 
			
		||||
    firstread=readPin(RTS_PIN);
 | 
			
		||||
   // printf("r%02X:", firstread);
 | 
			
		||||
 | 
			
		||||
    pinMode(RTS_PIN, PinDirectionOutput);
 | 
			
		||||
    setPinOutput(RTS_PIN);
 | 
			
		||||
 | 
			
		||||
    if (firstread == PinLevelHigh) {
 | 
			
		||||
        digitalWrite(RTS_PIN, PinLevelLow);
 | 
			
		||||
    if (firstread) {
 | 
			
		||||
        writePinLow(RTS_PIN);
 | 
			
		||||
    } 
 | 
			
		||||
     _delay_ms(10);
 | 
			
		||||
    digitalWrite(RTS_PIN, PinLevelHigh);  
 | 
			
		||||
    writePinHigh(RTS_PIN);
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
/* the future is Arm 
 | 
			
		||||
    if (palReadPad(RTS_PIN_IOPRT) == PinLevelLow)
 | 
			
		||||
    if (!palReadPad(RTS_PIN_IOPRT))
 | 
			
		||||
  {
 | 
			
		||||
    _delay_ms(10);
 | 
			
		||||
    palSetPadMode(RTS_PINn_IOPORT, PinDirectionOutput_PUSHPULL);
 | 
			
		||||
| 
						 | 
				
			
			@ -224,9 +223,9 @@ uint8_t handspring_handshake(void) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
uint8_t handspring_reset(void) {
 | 
			
		||||
    digitalWrite(VCC_PIN, PinLevelLow);
 | 
			
		||||
    writePinLow(VCC_PIN);
 | 
			
		||||
    _delay_ms(5);
 | 
			
		||||
    digitalWrite(VCC_PIN, PinLevelHigh);
 | 
			
		||||
    writePinHigh(VCC_PIN);
 | 
			
		||||
 | 
			
		||||
    if ( handspring_handshake() ) {
 | 
			
		||||
        last_activity = timer_read();
 | 
			
		||||
| 
						 | 
				
			
			@ -250,7 +249,7 @@ void matrix_init(void)
 | 
			
		|||
#endif
 | 
			
		||||
 | 
			
		||||
    print("power up\n");
 | 
			
		||||
    digitalWrite(VCC_PIN, PinLevelHigh);
 | 
			
		||||
    writePinHigh(VCC_PIN);
 | 
			
		||||
 | 
			
		||||
    // wait for DCD strobe from keyboard - it will do this 
 | 
			
		||||
    // up to 3 times, then the board needs the RTS toggled to try again
 | 
			
		||||
| 
						 | 
				
			
			@ -265,7 +264,7 @@ void matrix_init(void)
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
#else  /// Palm / HP  device with DCD
 | 
			
		||||
    while( digitalRead(DCD_PIN) != PinLevelHigh ) {;} 
 | 
			
		||||
    while( !readPin(DCD_PIN) ) {;} 
 | 
			
		||||
    print("dcd\n");
 | 
			
		||||
 | 
			
		||||
    rts_reset(); // at this point the keyboard should think all is well. 
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue