Added configs to allow switching to 328P variant boards #featureadd
This commit is contained in:
parent
5d3bd86363
commit
393c41b8dd
3 changed files with 61 additions and 3 deletions
|
|
@ -26,9 +26,9 @@ board_hardware.uart = uart0
|
||||||
board_hardware.bod = 1.8v
|
board_hardware.bod = 1.8v
|
||||||
board_hardware.eesave = yes
|
board_hardware.eesave = yes
|
||||||
|
|
||||||
[env:ATmega88P]
|
[env:ATmega328P]
|
||||||
platform = atmelavr
|
platform = atmelavr
|
||||||
board = ATmega88P
|
board = ATmega328P
|
||||||
framework = arduino
|
framework = arduino
|
||||||
lib_deps = Arduino
|
lib_deps = Arduino
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,12 @@
|
||||||
#include "pP_cmd.h"
|
#include "pP_cmd.h"
|
||||||
#include "pP_i2c_config.h"
|
#include "pP_i2c_config.h"
|
||||||
#include "pP_volatile.h"
|
#include "pP_volatile.h"
|
||||||
#include <Wire1.h>
|
#ifdef __AVR_ATmega328P__
|
||||||
|
#include <Wire.h>
|
||||||
|
#endif
|
||||||
|
#ifdef __AVR_ATmega328PB__
|
||||||
|
#include <Wire1.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
uint8_t command;
|
uint8_t command;
|
||||||
uint32_t value;
|
uint32_t value;
|
||||||
|
|
@ -36,7 +41,12 @@ void i2cReportConfig() {
|
||||||
i2cWrite(buffer, 16, VCCSW);
|
i2cWrite(buffer, 16, VCCSW);
|
||||||
i2cWrite(buffer, 18, voltMeterConstant);
|
i2cWrite(buffer, 18, voltMeterConstant);
|
||||||
memcpy(buffer + 22, PP_VERSION, length - 22);
|
memcpy(buffer + 22, PP_VERSION, length - 22);
|
||||||
|
#ifdef __AVR_ATmega328P__
|
||||||
|
Wire.write(buffer, length);
|
||||||
|
#endif
|
||||||
|
#ifdef __AVR_ATmega328PB__
|
||||||
Wire1.write(buffer, length);
|
Wire1.write(buffer, length);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void i2cReportState() {
|
void i2cReportState() {
|
||||||
|
|
@ -47,7 +57,12 @@ void i2cReportState() {
|
||||||
i2cWrite(buffer, 4, (int)((long)VFol * Vin / 1023));
|
i2cWrite(buffer, 4, (int)((long)VFol * Vin / 1023));
|
||||||
i2cWrite(buffer, 6, ERR_STATE);
|
i2cWrite(buffer, 6, ERR_STATE);
|
||||||
i2cWrite(buffer, 8, PZ_STATE);
|
i2cWrite(buffer, 8, PZ_STATE);
|
||||||
|
#ifdef __AVR_ATmega328P__
|
||||||
|
Wire.write(buffer, length);
|
||||||
|
#endif
|
||||||
|
#ifdef __AVR_ATmega328PB__
|
||||||
Wire1.write(buffer, length);
|
Wire1.write(buffer, length);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void i2cReply() {
|
void i2cReply() {
|
||||||
|
|
@ -68,9 +83,19 @@ void i2cInput(int bytesReceived) {
|
||||||
for (int a = 0; a < bytesReceived; a++) {
|
for (int a = 0; a < bytesReceived; a++) {
|
||||||
// Check length of message, drops anything longer than [longBytes]
|
// Check length of message, drops anything longer than [longBytes]
|
||||||
if (a == 0) {
|
if (a == 0) {
|
||||||
|
#ifdef __AVR_ATmega328P__
|
||||||
|
command = Wire.read();
|
||||||
|
#endif
|
||||||
|
#ifdef __AVR_ATmega328PB__
|
||||||
command = Wire1.read();
|
command = Wire1.read();
|
||||||
|
#endif
|
||||||
} else if (a == 1) {
|
} else if (a == 1) {
|
||||||
|
#ifdef __AVR_ATmega328P__
|
||||||
|
value = Wire.read();
|
||||||
|
#endif
|
||||||
|
#ifdef __AVR_ATmega328PB__
|
||||||
value = Wire1.read();
|
value = Wire1.read();
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
value = value << 8 | Wire1.read();
|
value = value << 8 | Wire1.read();
|
||||||
}
|
}
|
||||||
|
|
@ -124,7 +149,14 @@ void i2cInput(int bytesReceived) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void i2cInit() {
|
void i2cInit() {
|
||||||
|
#ifdef __AVR_ATmega328P__
|
||||||
|
Wire.begin(pP_i2c_address);
|
||||||
|
Wire.onRequest(i2cReply);
|
||||||
|
Wire.onReceive(i2cInput);
|
||||||
|
#endif
|
||||||
|
#ifdef __AVR_ATmega328PB__
|
||||||
Wire1.begin(pP_i2c_address);
|
Wire1.begin(pP_i2c_address);
|
||||||
Wire1.onRequest(i2cReply);
|
Wire1.onRequest(i2cReply);
|
||||||
Wire1.onReceive(i2cInput);
|
Wire1.onReceive(i2cInput);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ Default pins (based on Rev.2.x.xPCB layout)
|
||||||
* PD3 OC2B (Voltage Follower VRef PWM Out 'D3')
|
* PD3 OC2B (Voltage Follower VRef PWM Out 'D3')
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef __AVR_ATmega328PB__ // Pin assignments for 328PB variant
|
||||||
|
|
||||||
// Analog Pin Assignments
|
// Analog Pin Assignments
|
||||||
#define V_FOLLOW_PIN A0 // Sense pin to check Voltage Follower stage
|
#define V_FOLLOW_PIN A0 // Sense pin to check Voltage Follower stage
|
||||||
#define VCOMP_SENSE_PIN A1 // Sense pin to check comparator stage voltage
|
#define VCOMP_SENSE_PIN A1 // Sense pin to check comparator stage voltage
|
||||||
|
|
@ -32,3 +34,27 @@ Default pins (based on Rev.2.x.xPCB layout)
|
||||||
#define VCOMP_PWM 9 // PWM analog output pin for comparator adjustment
|
#define VCOMP_PWM 9 // PWM analog output pin for comparator adjustment
|
||||||
#define PZDET_PIN 16 // Digital input pin for detecting piezo connection
|
#define PZDET_PIN 16 // Digital input pin for detecting piezo connection
|
||||||
#define VCCSW_PIN 8 // VCC variable regulator switch pin
|
#define VCCSW_PIN 8 // VCC variable regulator switch pin
|
||||||
|
|
||||||
|
#endif //__AVR_ATmega328PB__
|
||||||
|
|
||||||
|
#ifdef __AVR_ATmega328P__ // Pin assignments for 328P variant
|
||||||
|
|
||||||
|
// Analog Pin Assignments
|
||||||
|
#define V_FOLLOW_PIN A0 // PC0 Sense pin to check Voltage Follower stage
|
||||||
|
#define VCOMP_SENSE_PIN A1 // PC1 Sense pin to check comparator stage voltage
|
||||||
|
|
||||||
|
// Digital Pin Assignments
|
||||||
|
#define TRG_OUT 7 // LED and Z-Min trigger output connected to digital pin 7
|
||||||
|
//#define TRG_OUT 13 // For testing on Atmega328/2560, Output is moved to onboard LED pin
|
||||||
|
#define Z_TRG 2 // the piezo is connected to INT0 / digital pin 2
|
||||||
|
#define ERR_LED 4 // LED will blink if optimal voltage range cannot be achieved
|
||||||
|
#define GADJ_R0 20 // PB6 Auto-adjust ladder pin assignments
|
||||||
|
#define GADJ_R1 21 // PB7 "
|
||||||
|
#define GADJ_R2 5 // PD5 "
|
||||||
|
#define GADJ_R3 6 // PD6 "
|
||||||
|
#define V_FOL_PWM 3 // PD3 PWM analog output pin for voltage follower adjustment
|
||||||
|
#define VCOMP_PWM 9 // PB1 PWM analog output pin for comparator adjustment
|
||||||
|
#define PZDET_PIN 16 // PC2 Digital input pin for detecting piezo connection
|
||||||
|
#define VCCSW_PIN 8 // PB0 VCC variable regulator switch pin
|
||||||
|
|
||||||
|
#endif //__AVR_ATmega328P__
|
||||||
Loading…
Reference in a new issue