Try port*100+pin, fix config dependency
This commit is contained in:
parent
ba8bc7ea80
commit
3066655727
@ -32,7 +32,7 @@
|
|||||||
#ifndef _MARLINSERIAL_H_
|
#ifndef _MARLINSERIAL_H_
|
||||||
#define _MARLINSERIAL_H_
|
#define _MARLINSERIAL_H_
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
#include "../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
#include <WString.h>
|
#include <WString.h>
|
||||||
|
|
||||||
|
@ -20,16 +20,12 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(TARGET_LPC1768)
|
#ifdef TARGET_LPC1768
|
||||||
|
|
||||||
void u8g_i2c_init(uint8_t options);
|
|
||||||
|
|
||||||
|
void u8g_i2c_init(uint8_t options);
|
||||||
uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos);
|
uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos);
|
||||||
|
|
||||||
uint8_t u8g_i2c_start(uint8_t sla);
|
uint8_t u8g_i2c_start(uint8_t sla);
|
||||||
|
|
||||||
uint8_t u8g_i2c_send_byte(uint8_t data);
|
uint8_t u8g_i2c_send_byte(uint8_t data);
|
||||||
|
|
||||||
void u8g_i2c_stop(void);
|
void u8g_i2c_stop(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -30,34 +30,34 @@
|
|||||||
* resulted in using about about 25% of the CPU's time.
|
* resulted in using about about 25% of the CPU's time.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(TARGET_LPC1768)
|
#ifdef TARGET_LPC1768
|
||||||
|
|
||||||
#include <LPC17xx.h>
|
#include <LPC17xx.h>
|
||||||
#include <lpc17xx_pinsel.h>
|
#include <lpc17xx_pinsel.h>
|
||||||
#include "src/core/macros.h"
|
#include "src/core/macros.h"
|
||||||
// #include "pinmapping.h"
|
//#include "pinmapping.h"
|
||||||
|
|
||||||
#define LPC_PORT_OFFSET (0x0020)
|
#define LPC_PORT_OFFSET (0x0020)
|
||||||
#define LPC_PIN(pin) (1UL << pin)
|
#define LPC_PIN(pin) (1UL << pin)
|
||||||
#define LPC_GPIO(port) ((volatile LPC_GPIO_TypeDef *)(LPC_GPIO0_BASE + LPC_PORT_OFFSET * port))
|
#define LPC_GPIO(port) ((volatile LPC_GPIO_TypeDef *)(LPC_GPIO0_BASE + LPC_PORT_OFFSET * port))
|
||||||
|
|
||||||
#define INPUT 0
|
#define INPUT 0
|
||||||
#define OUTPUT 1
|
#define OUTPUT 1
|
||||||
#define INPUT_PULLUP 2
|
#define INPUT_PULLUP 2
|
||||||
|
|
||||||
|
|
||||||
uint8_t LPC1768_PIN_PORT(const uint8_t pin);
|
uint8_t LPC1768_PIN_PORT(const uint8_t pin);
|
||||||
uint8_t LPC1768_PIN_PIN(const uint8_t pin);
|
uint8_t LPC1768_PIN_PIN(const uint8_t pin);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// IO functions
|
// I/O functions
|
||||||
// As defined by Arduino INPUT(0x0), OUPUT(0x1), INPUT_PULLUP(0x2)
|
// As defined by Arduino INPUT(0x0), OUPUT(0x1), INPUT_PULLUP(0x2)
|
||||||
void pinMode_LCD(uint8_t pin, uint8_t mode) {
|
void pinMode_LCD(uint8_t pin, uint8_t mode) {
|
||||||
#define LPC1768_PIN_PORT(pin) ((uint8_t)((pin >> 5) & 0b111))
|
#define LPC1768_PIN_PORT(pin) ((uint8_t)((pin >> 5) & 0b111))
|
||||||
#define LPC1768_PIN_PIN(pin) ((uint8_t)(pin & 0b11111))
|
#define LPC1768_PIN_PIN(pin) ((uint8_t)(pin & 0b11111))
|
||||||
PINSEL_CFG_Type config = { LPC1768_PIN_PORT(pin),
|
PINSEL_CFG_Type config = { LPC1768_PIN_PORT(pin),
|
||||||
LPC1768_PIN_PIN(pin),
|
LPC1768_PIN_PIN(pin),
|
||||||
PINSEL_FUNC_0,
|
PINSEL_FUNC_0,
|
||||||
@ -82,35 +82,32 @@ void pinMode_LCD(uint8_t pin, uint8_t mode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void u8g_SetPinOutput(uint8_t internal_pin_number) {
|
||||||
|
pinMode_LCD(internal_pin_number, 1); // OUTPUT
|
||||||
|
}
|
||||||
|
|
||||||
void u8g_SetPinOutput(uint8_t internal_pin_number) {
|
void u8g_SetPinInput(uint8_t internal_pin_number) {
|
||||||
pinMode_LCD(internal_pin_number, 1); // OUTPUT
|
pinMode_LCD(internal_pin_number, 0); // INPUT
|
||||||
|
}
|
||||||
|
|
||||||
|
void u8g_SetPinLevel(uint8_t pin, uint8_t pin_status) {
|
||||||
|
#define LPC1768_PIN_PORT(pin) ((uint8_t)((pin >> 5) & 0b111))
|
||||||
|
#define LPC1768_PIN_PIN(pin) ((uint8_t)(pin & 0b11111))
|
||||||
|
if (pin_status)
|
||||||
|
LPC_GPIO(LPC1768_PIN_PORT(pin))->FIOSET = LPC_PIN(LPC1768_PIN_PIN(pin));
|
||||||
|
else
|
||||||
|
LPC_GPIO(LPC1768_PIN_PORT(pin))->FIOCLR = LPC_PIN(LPC1768_PIN_PIN(pin));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t u8g_GetPinLevel(uint8_t pin) {
|
||||||
|
#define LPC1768_PIN_PORT(pin) ((uint8_t)((pin >> 5) & 0b111))
|
||||||
|
#define LPC1768_PIN_PIN(pin) ((uint8_t)(pin & 0b11111))
|
||||||
|
return (uint32_t)LPC_GPIO(LPC1768_PIN_PORT(pin))->FIOPIN & LPC_PIN(LPC1768_PIN_PIN(pin)) ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
||||||
void u8g_SetPinInput(uint8_t internal_pin_number) {
|
|
||||||
pinMode_LCD(internal_pin_number, 0); // INPUT
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void u8g_SetPinLevel(uint8_t pin, uint8_t pin_status) {
|
|
||||||
#define LPC1768_PIN_PORT(pin) ((uint8_t)((pin >> 5) & 0b111))
|
|
||||||
#define LPC1768_PIN_PIN(pin) ((uint8_t)(pin & 0b11111))
|
|
||||||
if (pin_status)
|
|
||||||
LPC_GPIO(LPC1768_PIN_PORT(pin))->FIOSET = LPC_PIN(LPC1768_PIN_PIN(pin));
|
|
||||||
else
|
|
||||||
LPC_GPIO(LPC1768_PIN_PORT(pin))->FIOCLR = LPC_PIN(LPC1768_PIN_PIN(pin));
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t u8g_GetPinLevel(uint8_t pin) {
|
|
||||||
#define LPC1768_PIN_PORT(pin) ((uint8_t)((pin >> 5) & 0b111))
|
|
||||||
#define LPC1768_PIN_PIN(pin) ((uint8_t)(pin & 0b11111))
|
|
||||||
return (uint32_t)LPC_GPIO(LPC1768_PIN_PORT(pin))->FIOPIN & LPC_PIN(LPC1768_PIN_PIN(pin)) ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // TARGET_LPC1768
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
#include "../../inc/MarlinConfig.h"
|
#include "../../inc/MarlinConfig.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "arduino.h"
|
#include "include/arduino.h"
|
||||||
#include "pinmapping.h"
|
#include "pinmapping.h"
|
||||||
#include "fastio.h"
|
#include "fastio.h"
|
||||||
#include "SoftwareSerial.h"
|
#include "SoftwareSerial.h"
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#ifndef SOFTWARESERIAL_H
|
#ifndef SOFTWARESERIAL_H
|
||||||
#define SOFTWARESERIAL_H
|
#define SOFTWARESERIAL_H
|
||||||
|
|
||||||
#include "arduino.h"
|
#include "include/arduino.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
//#include "serial.h"
|
//#include "serial.h"
|
||||||
#include <Stream.h>
|
#include <Stream.h>
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#define _FASTIO_LPC1768_H
|
#define _FASTIO_LPC1768_H
|
||||||
|
|
||||||
#include <LPC17xx.h>
|
#include <LPC17xx.h>
|
||||||
#include "arduino.h"
|
#include "include/arduino.h"
|
||||||
#include "pinmapping.h"
|
#include "pinmapping.h"
|
||||||
|
|
||||||
bool useable_hardware_PWM(pin_t pin);
|
bool useable_hardware_PWM(pin_t pin);
|
||||||
|
@ -30,7 +30,7 @@ extern "C" {
|
|||||||
#include "HAL_timers.h"
|
#include "HAL_timers.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "arduino.h"
|
#include "include/arduino.h"
|
||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
#include "LPC1768_PWM.h"
|
#include "LPC1768_PWM.h"
|
||||||
|
|
||||||
|
@ -22,32 +22,53 @@
|
|||||||
|
|
||||||
#ifdef TARGET_LPC1768
|
#ifdef TARGET_LPC1768
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
#include "pinmapping.h"
|
||||||
|
|
||||||
#include "../../gcode/parser.h"
|
#include "../../gcode/parser.h"
|
||||||
|
|
||||||
int16_t GET_PIN_MAP_INDEX(pin_t pin) {
|
// Get the digital pin for an analog index
|
||||||
const uint8_t pin_port = LPC1768_PIN_PORT(pin),
|
pin_t analogInputToDigitalPin(const uint8_t p) {
|
||||||
pin_pin = LPC1768_PIN_PIN(pin);
|
return (p < COUNT(adc_pin_table) ? adc_pin_table[p] : P_NC);
|
||||||
for (size_t i = 0; i < NUM_DIGITAL_PINS; ++i)
|
|
||||||
if (LPC1768_PIN_PORT(pin_map[i]) == pin_port && LPC1768_PIN_PIN(pin_map[i]) == pin_pin)
|
|
||||||
return i;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t PARSED_PIN_INDEX(char code, int16_t dval) { // treats 1.2 and 1.20 as the same thing
|
// Return the index of a pin number
|
||||||
if (parser.seenval(code)) {
|
// The pin number given here is in the form ppp:nnnnn
|
||||||
int port, pin;
|
int16_t GET_PIN_MAP_INDEX(const pin_t pin) {
|
||||||
char pin_string[3] = {" "};
|
const uint16_t index = (LPC1768_PIN_PORT(pin) << 5) | LPC1768_PIN_PIN(pin);
|
||||||
if (sscanf(parser.strval(code), "%d.%2s", &port, pin_string) == 2) {
|
return (index < NUM_DIGITAL_PINS && pin_map[index] != P_NC) ? index : -1;
|
||||||
if (pin_string[1] == '\0') pin_string[1] = '0'; // add trailing zero if a null is found
|
|
||||||
pin = (10 * (pin_string[0] - '0')) + (pin_string[1] - '0'); // convert string to number
|
|
||||||
for (size_t i = 0; i < NUM_DIGITAL_PINS; ++i)
|
|
||||||
if (LPC1768_PIN_PORT(pin_map[i]) == port && LPC1768_PIN_PIN(pin_map[i]) == pin)
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TARGET_LPC1768
|
// Test whether the pin is valid
|
||||||
|
bool VALID_PIN(const pin_t p) {
|
||||||
|
const int16_t ind = GET_PIN_MAP_INDEX(p);
|
||||||
|
return ind >= 0 && pin_map[ind] >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the analog index for a digital pin
|
||||||
|
int8_t DIGITAL_PIN_TO_ANALOG_PIN(const pin_t p) {
|
||||||
|
return (VALID_PIN(p) ? LPC1768_PIN_ADC(p) : -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test whether the pin is PWM
|
||||||
|
bool PWM_PIN(const pin_t p) {
|
||||||
|
return VALID_PIN(p) && LPC1768_PIN_PWM(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test whether the pin is interruptable
|
||||||
|
bool INTERRUPT_PIN(const pin_t p) {
|
||||||
|
return VALID_PIN(p) && LPC1768_PIN_INTERRUPT(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the pin number at the given index
|
||||||
|
pin_t GET_PIN_MAP_PIN(const int16_t ind) {
|
||||||
|
return WITHIN(ind, 0, NUM_DIGITAL_PINS - 1) ? pin_map[ind] : P_NC;
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) {
|
||||||
|
const uint16_t val = (uint16_t)parser.intval(code), port = val / 100, pin = val % 100;
|
||||||
|
const int16_t ind = (port < (NUM_DIGITAL_PINS >> 5) && (pin < 32))
|
||||||
|
? GET_PIN_MAP_INDEX(port << 5 | pin) : -2;
|
||||||
|
return ind > -2 ? ind : dval;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // TARGET_LPC1768
|
||||||
|
@ -20,10 +20,10 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __HAL_PINMAPPING_H__
|
#ifndef _PINMAPPING_H_
|
||||||
#define __HAL_PINMAPPING_H__
|
#define _PINMAPPING_H_
|
||||||
|
|
||||||
#include "../../core/macros.h"
|
#include "../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@ -94,6 +94,7 @@ typedef int16_t pin_t;
|
|||||||
#define INTERRUPT(b) BOOL_(b)
|
#define INTERRUPT(b) BOOL_(b)
|
||||||
#define PWM(b) BOOL_(b)
|
#define PWM(b) BOOL_(b)
|
||||||
|
|
||||||
|
// Combine elements into pin bits: 0b00AAAAWIPPPNNNNN
|
||||||
#define LPC1768_PIN_(port, pin, int, pwm, adc) 0b00##adc##pwm##int##port##pin
|
#define LPC1768_PIN_(port, pin, int, pwm, adc) 0b00##adc##pwm##int##port##pin
|
||||||
#define LPC1768_PIN(port, pin, int, pwm, adc) LPC1768_PIN_(port, pin, int, pwm, adc)
|
#define LPC1768_PIN(port, pin, int, pwm, adc) LPC1768_PIN_(port, pin, int, pwm, adc)
|
||||||
|
|
||||||
@ -106,7 +107,7 @@ constexpr int8_t LPC1768_PIN_ADC(const pin_t pin) { return (int8_t)((pin >> 10)
|
|||||||
// ******************
|
// ******************
|
||||||
// Runtime pinmapping
|
// Runtime pinmapping
|
||||||
// ******************
|
// ******************
|
||||||
#define P_NC -1
|
#define P_NC -1
|
||||||
|
|
||||||
#if SERIAL_PORT != 3
|
#if SERIAL_PORT != 3
|
||||||
#define P0_00 LPC1768_PIN(PORT(0), PIN( 0), INTERRUPT(1), PWM(0), ADC_NONE)
|
#define P0_00 LPC1768_PIN(PORT(0), PIN( 0), INTERRUPT(1), PWM(0), ADC_NONE)
|
||||||
@ -187,46 +188,58 @@ constexpr int8_t LPC1768_PIN_ADC(const pin_t pin) { return (int8_t)((pin >> 10)
|
|||||||
#define P4_28 LPC1768_PIN(PORT(4), PIN(28), INTERRUPT(0), PWM(0), ADC_NONE)
|
#define P4_28 LPC1768_PIN(PORT(4), PIN(28), INTERRUPT(0), PWM(0), ADC_NONE)
|
||||||
#define P4_29 LPC1768_PIN(PORT(4), PIN(29), INTERRUPT(0), PWM(0), ADC_NONE)
|
#define P4_29 LPC1768_PIN(PORT(4), PIN(29), INTERRUPT(0), PWM(0), ADC_NONE)
|
||||||
|
|
||||||
constexpr bool VALID_PIN(const pin_t p) {
|
// Pin index for M43 and M226
|
||||||
return (
|
constexpr pin_t pin_map[] = {
|
||||||
#if SERIAL_PORT == 0
|
#if SERIAL_PORT != 3
|
||||||
(LPC1768_PIN_PORT(p) == 0 && LPC1768_PIN_PIN(p) <= 1) ||
|
P0_00, P0_01,
|
||||||
(LPC1768_PIN_PORT(p) == 0 && WITHIN(LPC1768_PIN_PIN(p), 4, 11)) ||
|
#else
|
||||||
#elif SERIAL_PORT == 2
|
P_NC, P_NC,
|
||||||
(LPC1768_PIN_PORT(p) == 0 && LPC1768_PIN_PIN(p) <= 9) ||
|
#endif
|
||||||
#elif SERIAL_PORT == 3
|
#if SERIAL_PORT != 0
|
||||||
(LPC1768_PIN_PORT(p) == 0 && WITHIN(LPC1768_PIN_PIN(p), 2, 11)) ||
|
P0_02, P0_03,
|
||||||
#else
|
#else
|
||||||
(LPC1768_PIN_PORT(p) == 0 && LPC1768_PIN_PIN(p) <= 11) ||
|
P_NC, P_NC,
|
||||||
#endif
|
#endif
|
||||||
#if SERIAL_PORT == 1
|
P0_04, P0_05, P0_06, P0_07,
|
||||||
(LPC1768_PIN_PORT(p) == 0 && WITHIN(LPC1768_PIN_PIN(p), 17, 30)) ||
|
P0_08, P0_09,
|
||||||
#else
|
#if SERIAL_PORT != 2
|
||||||
(LPC1768_PIN_PORT(p) == 0 && WITHIN(LPC1768_PIN_PIN(p), 15, 30)) ||
|
P0_10, P0_11,
|
||||||
#endif
|
#else
|
||||||
(LPC1768_PIN_PORT(p) == 1 && LPC1768_PIN_PIN(p) == 1) ||
|
P_NC, P_NC,
|
||||||
(LPC1768_PIN_PORT(p) == 1 && LPC1768_PIN_PIN(p) == 4) ||
|
#endif
|
||||||
(LPC1768_PIN_PORT(p) == 1 && WITHIN(LPC1768_PIN_PIN(p), 8, 10)) ||
|
P_NC, P_NC, P_NC,
|
||||||
(LPC1768_PIN_PORT(p) == 1 && WITHIN(LPC1768_PIN_PIN(p), 14, 31)) ||
|
#if SERIAL_PORT != 1
|
||||||
(LPC1768_PIN_PORT(p) == 2 && LPC1768_PIN_PIN(p) <= 13) ||
|
P0_15,
|
||||||
(LPC1768_PIN_PORT(p) == 3 && WITHIN(LPC1768_PIN_PIN(p), 25, 26)) ||
|
P0_16,
|
||||||
(LPC1768_PIN_PORT(p) == 4 && WITHIN(LPC1768_PIN_PIN(p), 28, 29))
|
#else
|
||||||
);
|
P_NC,
|
||||||
}
|
P_NC,
|
||||||
|
#endif
|
||||||
|
P0_17, P0_18, P0_19, P0_20, P0_21, P0_22, P0_23,
|
||||||
|
P0_24, P0_25, P0_26, P0_27, P0_28, P0_29, P0_30, P_NC,
|
||||||
|
|
||||||
constexpr bool PWM_PIN(const pin_t p) {
|
P1_00, P1_01, P_NC, P_NC, P1_04, P_NC, P_NC, P_NC,
|
||||||
return (VALID_PIN(p) && LPC1768_PIN_PWM(p));
|
P1_08, P1_09, P1_10, P_NC, P_NC, P_NC, P1_14, P1_15,
|
||||||
}
|
P1_16, P1_17, P1_18, P1_19, P1_20, P1_21, P1_22, P1_23,
|
||||||
|
P1_24, P1_25, P1_26, P1_27, P1_28, P1_29, P1_30, P1_31,
|
||||||
|
|
||||||
constexpr bool INTERRUPT_PIN(const pin_t p) {
|
P2_00, P2_01, P2_02, P2_03, P2_04, P2_05, P2_06, P2_07,
|
||||||
return (VALID_PIN(p) && LPC1768_PIN_INTERRUPT(p));
|
P2_08, P2_09, P2_10, P2_11, P2_12, P2_13, P_NC, P_NC,
|
||||||
}
|
P_NC, P_NC, P_NC, P_NC, P_NC, P_NC, P_NC, P_NC,
|
||||||
|
P_NC, P_NC, P_NC, P_NC, P_NC, P_NC, P_NC, P_NC,
|
||||||
|
|
||||||
#if SERIAL_PORT == 0
|
P_NC, P_NC, P_NC, P_NC, P_NC, P_NC, P_NC, P_NC,
|
||||||
#define NUM_ANALOG_INPUTS 6
|
P_NC, P_NC, P_NC, P_NC, P_NC, P_NC, P_NC, P_NC,
|
||||||
#else
|
P_NC, P_NC, P_NC, P_NC, P_NC, P_NC, P_NC, P_NC,
|
||||||
#define NUM_ANALOG_INPUTS 8
|
P_NC, P3_25, P3_26, P_NC, P_NC, P_NC, P_NC, P_NC,
|
||||||
#endif
|
|
||||||
|
P_NC, P_NC, P_NC, P_NC, P_NC, P_NC, P_NC, P_NC,
|
||||||
|
P_NC, P_NC, P_NC, P_NC, P_NC, P_NC, P_NC, P_NC,
|
||||||
|
P_NC, P_NC, P_NC, P_NC, P_NC, P_NC, P_NC, P_NC,
|
||||||
|
P_NC, P_NC, P_NC, P_NC, P4_28, P4_29, P_NC, P_NC
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr int16_t NUM_DIGITAL_PINS = COUNT(pin_map);
|
||||||
|
|
||||||
constexpr pin_t adc_pin_table[] = {
|
constexpr pin_t adc_pin_table[] = {
|
||||||
P0_23, P0_24, P0_25, P0_26, P1_30, P1_31,
|
P0_23, P0_24, P0_25, P0_26, P1_30, P1_31,
|
||||||
@ -235,49 +248,35 @@ constexpr pin_t adc_pin_table[] = {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr pin_t analogInputToDigitalPin(const uint8_t p) {
|
constexpr int16_t NUM_ANALOG_INPUTS = COUNT(adc_pin_table);
|
||||||
return (p < COUNT(adc_pin_table) ? adc_pin_table[p] : P_NC);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr int8_t DIGITAL_PIN_TO_ANALOG_PIN(const pin_t p) {
|
|
||||||
return (VALID_PIN(p) ? LPC1768_PIN_ADC(p) : -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// P0.6 thru P0.9 are for the onboard SD card
|
// P0.6 thru P0.9 are for the onboard SD card
|
||||||
// P0.29 and P0.30 are for the USB port
|
// P0.29 and P0.30 are for the USB port
|
||||||
#define HAL_SENSITIVE_PINS P0_06, P0_07, P0_08, P0_09, P0_29, P0_30
|
#define HAL_SENSITIVE_PINS P0_06, P0_07, P0_08, P0_09, P0_29, P0_30
|
||||||
|
|
||||||
// Pin map for M43 and M226
|
// Get the digital pin for an analog index
|
||||||
const pin_t pin_map[] = {
|
pin_t analogInputToDigitalPin(const uint8_t p);
|
||||||
#if SERIAL_PORT != 3
|
|
||||||
P0_00, P0_01,
|
|
||||||
#endif
|
|
||||||
#if SERIAL_PORT != 0
|
|
||||||
P0_02, P0_03,
|
|
||||||
#endif
|
|
||||||
P0_04, P0_05, P0_06, P0_07, P0_08, P0_09,
|
|
||||||
#if SERIAL_PORT != 2
|
|
||||||
P0_10, P0_11,
|
|
||||||
#endif
|
|
||||||
#if SERIAL_PORT != 1
|
|
||||||
P0_15, P0_16,
|
|
||||||
#endif
|
|
||||||
P0_17, P0_18, P0_19, P0_20, P0_21, P0_22, P0_23, P0_24,
|
|
||||||
P0_25, P0_26, P0_27, P0_28, P0_29, P0_30,
|
|
||||||
P1_00, P1_01, P1_04, P1_08, P1_09, P1_10, P1_14, P1_15,
|
|
||||||
P1_16, P1_17, P1_18, P1_19, P1_20, P1_21, P1_22, P1_23,
|
|
||||||
P1_24, P1_25, P1_26, P1_27, P1_28, P1_29, P1_30, P1_31,
|
|
||||||
P2_00, P2_01, P2_02, P2_03, P2_04, P2_05, P2_06, P2_07,
|
|
||||||
P2_08, P2_09, P2_10, P2_11, P2_12, P2_13,
|
|
||||||
P3_25, P3_26,
|
|
||||||
P4_28, P4_29
|
|
||||||
};
|
|
||||||
|
|
||||||
#define NUM_DIGITAL_PINS COUNT(pin_map)
|
// Return the index of a pin number
|
||||||
|
// The pin number given here is in the form ppp:nnnnn
|
||||||
|
int16_t GET_PIN_MAP_INDEX(const pin_t pin);
|
||||||
|
|
||||||
#define GET_PIN_MAP_PIN(i) (WITHIN(i, 0, (int)NUM_DIGITAL_PINS - 1) ? pin_map[i] : -1)
|
// Test whether the pin is valid
|
||||||
|
bool VALID_PIN(const pin_t p);
|
||||||
|
|
||||||
int16_t GET_PIN_MAP_INDEX(pin_t pin);
|
// Get the analog index for a digital pin
|
||||||
int16_t PARSED_PIN_INDEX(char code, int16_t dval = 0);
|
int8_t DIGITAL_PIN_TO_ANALOG_PIN(const pin_t p);
|
||||||
|
|
||||||
#endif // __HAL_PINMAPPING_H__
|
// Test whether the pin is PWM
|
||||||
|
bool PWM_PIN(const pin_t p);
|
||||||
|
|
||||||
|
// Test whether the pin is interruptable
|
||||||
|
bool INTERRUPT_PIN(const pin_t p);
|
||||||
|
|
||||||
|
// Get the pin number at the given index
|
||||||
|
pin_t GET_PIN_MAP_PIN(const int16_t ind);
|
||||||
|
|
||||||
|
// Parse a G-code word into a pin index
|
||||||
|
int16_t PARSED_PIN_INDEX(const char code, const int16_t dval);
|
||||||
|
|
||||||
|
#endif // _PINMAPPING_H_
|
||||||
|
@ -28,7 +28,9 @@
|
|||||||
* M42: Change pin status via GCode
|
* M42: Change pin status via GCode
|
||||||
*
|
*
|
||||||
* P<pin> Pin number (LED if omitted)
|
* P<pin> Pin number (LED if omitted)
|
||||||
* For LPC1768 enter pin P1_20 as M42 P1.20
|
* For LPC1768 specify pin P1_02 as M42 P102,
|
||||||
|
* P1_20 as M42 P120, etc.
|
||||||
|
*
|
||||||
* S<byte> Pin status from 0 - 255
|
* S<byte> Pin status from 0 - 255
|
||||||
*/
|
*/
|
||||||
void GcodeSuite::M42() {
|
void GcodeSuite::M42() {
|
||||||
|
@ -23,13 +23,8 @@
|
|||||||
#ifndef MARLIN_CONFIG_H
|
#ifndef MARLIN_CONFIG_H
|
||||||
#define MARLIN_CONFIG_H
|
#define MARLIN_CONFIG_H
|
||||||
|
|
||||||
#include "../core/boards.h"
|
#include "MarlinConfigPre.h"
|
||||||
#include "../core/macros.h"
|
|
||||||
#include "Version.h"
|
|
||||||
#include "../../Configuration.h"
|
|
||||||
#include "Conditionals_LCD.h"
|
|
||||||
#include "../../Configuration_adv.h"
|
|
||||||
#include "Conditionals_adv.h"
|
|
||||||
#include "../HAL/HAL.h"
|
#include "../HAL/HAL.h"
|
||||||
#include "../pins/pins.h"
|
#include "../pins/pins.h"
|
||||||
#if defined(__AVR__) && !defined(USBCON)
|
#if defined(__AVR__) && !defined(USBCON)
|
||||||
|
34
Marlin/src/inc/MarlinConfigPre.h
Normal file
34
Marlin/src/inc/MarlinConfigPre.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
* Marlin 3D Printer Firmware
|
||||||
|
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MARLIN_CONFIGPRE_H
|
||||||
|
#define MARLIN_CONFIGPRE_H
|
||||||
|
|
||||||
|
#include "../core/boards.h"
|
||||||
|
#include "../core/macros.h"
|
||||||
|
#include "Version.h"
|
||||||
|
#include "../../Configuration.h"
|
||||||
|
#include "Conditionals_LCD.h"
|
||||||
|
#include "../../Configuration_adv.h"
|
||||||
|
#include "Conditionals_adv.h"
|
||||||
|
|
||||||
|
#endif // MARLIN_CONFIGPRE_H
|
@ -23,12 +23,12 @@
|
|||||||
#ifndef _VERSION_H_
|
#ifndef _VERSION_H_
|
||||||
#define _VERSION_H_
|
#define _VERSION_H_
|
||||||
|
|
||||||
#include "MarlinConfig.h"
|
#include "../core/macros.h" // for ENABLED
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is the standard Marlin version identifier file, all fields can be
|
* This file is the standard Marlin version identifier file.
|
||||||
* overriden by the ones defined in _Version.h by using the Configuration.h
|
* Use -DUSE_AUTOMATIC_VERSIONING=1 and a custom _Version.h
|
||||||
* directive USE_AUTOMATIC_VERSIONING.
|
* to override these values.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if ENABLED(USE_AUTOMATIC_VERSIONING)
|
#if ENABLED(USE_AUTOMATIC_VERSIONING)
|
||||||
|
Loading…
Reference in New Issue
Block a user