2017-10-08 18:38:10 +02:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2019-02-12 22:06:53 +01:00
|
|
|
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-10-08 18:38:10 +02:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
|
|
|
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2018-11-04 09:25:55 +01:00
|
|
|
#pragma once
|
2017-10-08 18:38:10 +02:00
|
|
|
|
2019-02-10 12:40:31 +01:00
|
|
|
#include "i2s.h"
|
|
|
|
|
2017-10-08 18:38:10 +02:00
|
|
|
/**
|
|
|
|
* Utility functions
|
|
|
|
*/
|
|
|
|
|
2019-02-10 12:40:31 +01:00
|
|
|
// Set pin as input
|
2019-03-13 12:51:15 +01:00
|
|
|
#define _SET_INPUT(IO) pinMode(IO, INPUT)
|
2017-10-08 18:38:10 +02:00
|
|
|
|
2019-02-10 12:40:31 +01:00
|
|
|
// Set pin as output
|
2019-03-13 12:51:15 +01:00
|
|
|
#define _SET_OUTPUT(IO) pinMode(IO, OUTPUT)
|
2017-10-08 18:38:10 +02:00
|
|
|
|
2019-02-10 12:40:31 +01:00
|
|
|
// Set pin as input with pullup mode
|
2019-03-13 12:51:15 +01:00
|
|
|
#define _PULLUP(IO, v) pinMode(IO, v ? INPUT_PULLUP : INPUT)
|
2017-10-08 18:38:10 +02:00
|
|
|
|
|
|
|
// Read a pin wrapper
|
2019-04-18 20:15:35 +02:00
|
|
|
#define READ(IO) (TEST(IO, 7) ? i2s_state(IO & 0x7F) : digitalRead(IO))
|
2017-10-08 18:38:10 +02:00
|
|
|
|
|
|
|
// Write to a pin wrapper
|
2019-03-13 12:51:15 +01:00
|
|
|
#define WRITE(IO, v) (TEST(IO, 7) ? i2s_write(IO & 0x7F, v) : digitalWrite(IO, v))
|
2017-10-08 18:38:10 +02:00
|
|
|
|
2019-02-10 12:40:31 +01:00
|
|
|
// Set pin as input wrapper
|
2019-03-13 12:51:15 +01:00
|
|
|
#define SET_INPUT(IO) _SET_INPUT(IO)
|
2017-10-08 18:38:10 +02:00
|
|
|
|
2019-02-10 12:40:31 +01:00
|
|
|
// Set pin as input with pullup wrapper
|
2019-03-13 12:51:15 +01:00
|
|
|
#define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _PULLUP(IO, HIGH); }while(0)
|
2017-10-08 18:38:10 +02:00
|
|
|
|
2019-02-10 12:40:31 +01:00
|
|
|
// Set pin as output wrapper
|
2019-03-13 12:51:15 +01:00
|
|
|
#define SET_OUTPUT(IO) do{ _SET_OUTPUT(IO); }while(0)
|
2017-10-08 18:38:10 +02:00
|
|
|
|
2019-03-13 12:51:15 +01:00
|
|
|
// Set pin as PWM
|
|
|
|
#define SET_PWM(IO) SET_OUTPUT(IO)
|
|
|
|
|
|
|
|
// Set pin as output and init
|
|
|
|
#define OUT_WRITE(IO,V) do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
|
2017-10-08 18:38:10 +02:00
|
|
|
|
2019-03-05 07:41:31 +01:00
|
|
|
// digitalRead/Write wrappers
|
2019-03-13 12:51:15 +01:00
|
|
|
#define extDigitalRead(IO) digitalRead(IO)
|
|
|
|
#define extDigitalWrite(IO,V) digitalWrite(IO,V)
|
|
|
|
|
|
|
|
#define PWM_PIN(P) true
|
|
|
|
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
|
2019-03-05 07:41:31 +01:00
|
|
|
|
2019-04-05 06:15:17 +02:00
|
|
|
// Toggle pin value
|
|
|
|
#define TOGGLE(IO) WRITE(IO, !READ(IO))
|
|
|
|
|
2017-10-08 18:38:10 +02:00
|
|
|
//
|
2019-02-10 12:40:31 +01:00
|
|
|
// Ports and functions
|
2017-10-08 18:38:10 +02:00
|
|
|
//
|
|
|
|
|
|
|
|
// UART
|
|
|
|
#define RXD 3
|
|
|
|
#define TXD 1
|
|
|
|
|
|
|
|
// TWI (I2C)
|
|
|
|
#define SCL 5
|
|
|
|
#define SDA 4
|