Make LPC1768 pinmapping not specific to Re-ARM (#8063)

* Merging early because of build failures.  See #8105

* Make LPC1768 pinmapping not specific to Re-ARM

* Add HAL_PIN_TYPE and LPC1768 pin features

* M43 Updates

* Move pin map into pinsDebug_LPC1768.h

* Incorporate comments and M226

* Fix persistent store compilation issues

* Update pin features

* Update MKS SBASE pins

* Use native LPC1768 pin numbers in M42, M43, and M226
This commit is contained in:
Thomas Moore
2017-10-26 13:37:26 -05:00
committed by Roxy-3D
parent e4266d0fde
commit 9e699811d2
49 changed files with 1176 additions and 1338 deletions

View File

@@ -81,14 +81,16 @@ void HAL_adc_init(void) {
extern void kill(const char*);
extern const char errormagic[];
void HAL_adc_enable_channel(int pin) {
if (!WITHIN(pin, 0, NUM_ANALOG_INPUTS - 1)) {
MYSERIAL.printf("%sINVALID ANALOG PORT:%d\n", errormagic, pin);
void HAL_adc_enable_channel(int ch) {
pin_t pin = analogInputToDigitalPin(ch);
if (pin == -1) {
MYSERIAL.printf("%sINVALID ANALOG PORT:%d\n", errormagic, ch);
kill(MSG_KILLED);
}
int8_t pin_port = adc_pin_map[pin].port,
pin_port_pin = adc_pin_map[pin].pin,
int8_t pin_port = LPC1768_PIN_PORT(pin),
pin_port_pin = LPC1768_PIN_PIN(pin),
pinsel_start_bit = pin_port_pin > 15 ? 2 * (pin_port_pin - 16) : 2 * pin_port_pin;
uint8_t pin_sel_register = (pin_port == 0 && pin_port_pin <= 15) ? 0 :
pin_port == 0 ? 1 :
@@ -111,15 +113,16 @@ void HAL_adc_enable_channel(int pin) {
}
uint8_t active_adc = 0;
void HAL_adc_start_conversion(const uint8_t adc_pin) {
if (adc_pin >= (NUM_ANALOG_INPUTS) || adc_pin_map[adc_pin].port == 0xFF) {
MYSERIAL.printf("HAL: HAL_adc_start_conversion: no pinmap for %d\n", adc_pin);
void HAL_adc_start_conversion(const uint8_t ch) {
if (analogInputToDigitalPin(ch) == -1) {
MYSERIAL.printf("HAL: HAL_adc_start_conversion: invalid channel %d\n", ch);
return;
}
LPC_ADC->ADCR &= ~0xFF; // Reset
SBI(LPC_ADC->ADCR, adc_pin_map[adc_pin].adc); // Select Channel
SBI(LPC_ADC->ADCR, 24); // Start conversion
active_adc = adc_pin;
LPC_ADC->ADCR &= ~0xFF; // Reset
SBI(LPC_ADC->ADCR, ch); // Select Channel
SBI(LPC_ADC->ADCR, 24); // Start conversion
active_adc = ch;
}
bool HAL_adc_finished(void) {