Add ArduinoISP sketch, system diagram, and update KiCAD project files
This commit is contained in:
734
Arduino/ArduinoISP_ProMicro/ArduinoISP_ProMicro.ino
Normal file
734
Arduino/ArduinoISP_ProMicro/ArduinoISP_ProMicro.ino
Normal file
@@ -0,0 +1,734 @@
|
|||||||
|
// ArduinoISP
|
||||||
|
// Copyright (c) 2008-2011 Randall Bohn
|
||||||
|
// If you require a license, see
|
||||||
|
// https://opensource.org/licenses/bsd-license.php
|
||||||
|
//
|
||||||
|
// This sketch turns the Arduino into a AVRISP using the following Arduino pins:
|
||||||
|
//
|
||||||
|
// Pin 10 is used to reset the target microcontroller.
|
||||||
|
//
|
||||||
|
// By default, the hardware SPI pins MISO, MOSI and SCK are used to communicate
|
||||||
|
// with the target. On all Arduinos, these pins can be found
|
||||||
|
// on the ICSP/SPI header:
|
||||||
|
//
|
||||||
|
// MISO °. . 5V (!) Avoid this pin on Due, Zero...
|
||||||
|
// SCK . . MOSI
|
||||||
|
// . . GND
|
||||||
|
//
|
||||||
|
// On some Arduinos (Uno,...), pins MOSI, MISO and SCK are the same pins as
|
||||||
|
// digital pin 11, 12 and 13, respectively. That is why many tutorials instruct
|
||||||
|
// you to hook up the target to these pins. If you find this wiring more
|
||||||
|
// practical, have a define USE_OLD_STYLE_WIRING. This will work even when not
|
||||||
|
// using an Uno. (On an Uno this is not needed).
|
||||||
|
//
|
||||||
|
// Alternatively you can use any other digital pin by configuring
|
||||||
|
// software ('BitBanged') SPI and having appropriate defines for PIN_MOSI,
|
||||||
|
// PIN_MISO and PIN_SCK.
|
||||||
|
//
|
||||||
|
// IMPORTANT: When using an Arduino that is not 5V tolerant (Due, Zero, ...) as
|
||||||
|
// the programmer, make sure to not expose any of the programmer's pins to 5V.
|
||||||
|
// A simple way to accomplish this is to power the complete system (programmer
|
||||||
|
// and target) at 3V3.
|
||||||
|
//
|
||||||
|
// Put an LED (with resistor) on the following pins:
|
||||||
|
// 9: Heartbeat - shows the programmer is running
|
||||||
|
// 8: Error - Lights up if something goes wrong (use red if that makes sense)
|
||||||
|
// 7: Programming - In communication with the slave
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "Arduino.h"
|
||||||
|
#undef SERIAL
|
||||||
|
|
||||||
|
|
||||||
|
#define PROG_FLICKER true
|
||||||
|
|
||||||
|
// Configure SPI clock (in Hz).
|
||||||
|
// E.g. for an ATtiny @ 128 kHz: the datasheet states that both the high and low
|
||||||
|
// SPI clock pulse must be > 2 CPU cycles, so take 3 cycles i.e. divide target
|
||||||
|
// f_cpu by 6:
|
||||||
|
// #define SPI_CLOCK (128000/6)
|
||||||
|
//
|
||||||
|
// A clock slow enough for an ATtiny85 @ 1 MHz, is a reasonable default:
|
||||||
|
|
||||||
|
#define SPI_CLOCK (1000000/6)
|
||||||
|
|
||||||
|
|
||||||
|
// Select hardware or software SPI, depending on SPI clock.
|
||||||
|
// Currently only for AVR, for other architectures (Due, Zero,...), hardware SPI
|
||||||
|
// is probably too fast anyway.
|
||||||
|
|
||||||
|
#if defined(ARDUINO_ARCH_AVR)
|
||||||
|
|
||||||
|
#if SPI_CLOCK > (F_CPU / 128)
|
||||||
|
#define USE_HARDWARE_SPI
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Configure which pins to use:
|
||||||
|
|
||||||
|
// The standard pin configuration.
|
||||||
|
#ifndef ARDUINO_HOODLOADER2
|
||||||
|
|
||||||
|
#define RESET 10 // Use pin 10 to reset the target rather than SS
|
||||||
|
#define LED_HB 9
|
||||||
|
#define LED_ERR 8
|
||||||
|
#define LED_PMODE 7
|
||||||
|
|
||||||
|
// Uncomment following line to use the old Uno style wiring
|
||||||
|
// (using pin 11, 12 and 13 instead of the SPI header) on Leonardo, Due...
|
||||||
|
|
||||||
|
// #define USE_OLD_STYLE_WIRING
|
||||||
|
|
||||||
|
#ifdef USE_OLD_STYLE_WIRING
|
||||||
|
|
||||||
|
#define PIN_MOSI 16
|
||||||
|
#define PIN_MISO 14
|
||||||
|
#define PIN_SCK 15
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// HOODLOADER2 means running sketches on the ATmega16U2 serial converter chips
|
||||||
|
// on Uno or Mega boards. We must use pins that are broken out:
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define RESET 4
|
||||||
|
#define LED_HB 7
|
||||||
|
#define LED_ERR 6
|
||||||
|
#define LED_PMODE 5
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// By default, use hardware SPI pins:
|
||||||
|
#ifndef PIN_MOSI
|
||||||
|
#define PIN_MOSI MOSI
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PIN_MISO
|
||||||
|
#define PIN_MISO MISO
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PIN_SCK
|
||||||
|
#define PIN_SCK SCK
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Force bitbanged SPI if not using the hardware SPI pins:
|
||||||
|
#if (PIN_MISO != MISO) || (PIN_MOSI != MOSI) || (PIN_SCK != SCK)
|
||||||
|
#undef USE_HARDWARE_SPI
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// Configure the serial port to use.
|
||||||
|
//
|
||||||
|
// Prefer the USB virtual serial port (aka. native USB port), if the Arduino has one:
|
||||||
|
// - it does not autoreset (except for the magic baud rate of 1200).
|
||||||
|
// - it is more reliable because of USB handshaking.
|
||||||
|
//
|
||||||
|
// Leonardo and similar have an USB virtual serial port: 'Serial'.
|
||||||
|
// Due and Zero have an USB virtual serial port: 'SerialUSB'.
|
||||||
|
//
|
||||||
|
// On the Due and Zero, 'Serial' can be used too, provided you disable autoreset.
|
||||||
|
// To use 'Serial': #define SERIAL Serial
|
||||||
|
|
||||||
|
#ifdef SERIAL_PORT_USBVIRTUAL
|
||||||
|
#define SERIAL SERIAL_PORT_USBVIRTUAL
|
||||||
|
#else
|
||||||
|
#define SERIAL Serial
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// Configure the baud rate:
|
||||||
|
|
||||||
|
#define BAUDRATE 19200
|
||||||
|
// #define BAUDRATE 115200
|
||||||
|
// #define BAUDRATE 1000000
|
||||||
|
|
||||||
|
|
||||||
|
#define HWVER 2
|
||||||
|
#define SWMAJ 1
|
||||||
|
#define SWMIN 18
|
||||||
|
|
||||||
|
// STK Definitions
|
||||||
|
#define STK_OK 0x10
|
||||||
|
#define STK_FAILED 0x11
|
||||||
|
#define STK_UNKNOWN 0x12
|
||||||
|
#define STK_INSYNC 0x14
|
||||||
|
#define STK_NOSYNC 0x15
|
||||||
|
#define CRC_EOP 0x20 //ok it is a space...
|
||||||
|
|
||||||
|
void pulse(int pin, int times);
|
||||||
|
|
||||||
|
#ifdef USE_HARDWARE_SPI
|
||||||
|
#include "SPI.h"
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define SPI_MODE0 0x00
|
||||||
|
|
||||||
|
#if !defined(ARDUINO_API_VERSION) || ARDUINO_API_VERSION != 10001 // A SPISettings class is declared by ArduinoCore-API 1.0.1
|
||||||
|
class SPISettings {
|
||||||
|
public:
|
||||||
|
// clock is in Hz
|
||||||
|
SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) : clockFreq(clock) {
|
||||||
|
(void) bitOrder;
|
||||||
|
(void) dataMode;
|
||||||
|
};
|
||||||
|
|
||||||
|
uint32_t getClockFreq() const {
|
||||||
|
return clockFreq;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32_t clockFreq;
|
||||||
|
};
|
||||||
|
#endif // !defined(ARDUINO_API_VERSION)
|
||||||
|
|
||||||
|
class BitBangedSPI {
|
||||||
|
public:
|
||||||
|
void begin() {
|
||||||
|
digitalWrite(PIN_SCK, LOW);
|
||||||
|
digitalWrite(PIN_MOSI, LOW);
|
||||||
|
pinMode(PIN_SCK, OUTPUT);
|
||||||
|
pinMode(PIN_MOSI, OUTPUT);
|
||||||
|
pinMode(PIN_MISO, INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void beginTransaction(SPISettings settings) {
|
||||||
|
pulseWidth = (500000 + settings.getClockFreq() - 1) / settings.getClockFreq();
|
||||||
|
if (pulseWidth == 0) {
|
||||||
|
pulseWidth = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void end() {}
|
||||||
|
|
||||||
|
uint8_t transfer(uint8_t b) {
|
||||||
|
for (unsigned int i = 0; i < 8; ++i) {
|
||||||
|
digitalWrite(PIN_MOSI, (b & 0x80) ? HIGH : LOW);
|
||||||
|
digitalWrite(PIN_SCK, HIGH);
|
||||||
|
delayMicroseconds(pulseWidth);
|
||||||
|
b = (b << 1) | digitalRead(PIN_MISO);
|
||||||
|
digitalWrite(PIN_SCK, LOW); // slow pulse
|
||||||
|
delayMicroseconds(pulseWidth);
|
||||||
|
}
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
unsigned long pulseWidth; // in microseconds
|
||||||
|
};
|
||||||
|
|
||||||
|
static BitBangedSPI SPI;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
SERIAL.begin(BAUDRATE);
|
||||||
|
|
||||||
|
pinMode(LED_PMODE, OUTPUT);
|
||||||
|
pulse(LED_PMODE, 2);
|
||||||
|
pinMode(LED_ERR, OUTPUT);
|
||||||
|
pulse(LED_ERR, 2);
|
||||||
|
pinMode(LED_HB, OUTPUT);
|
||||||
|
pulse(LED_HB, 2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int ISPError = 0;
|
||||||
|
int pmode = 0;
|
||||||
|
// address for reading and writing, set by 'U' command
|
||||||
|
unsigned int here;
|
||||||
|
uint8_t buff[256]; // global block storage
|
||||||
|
|
||||||
|
#define beget16(addr) (*addr * 256 + *(addr+1) )
|
||||||
|
typedef struct param {
|
||||||
|
uint8_t devicecode;
|
||||||
|
uint8_t revision;
|
||||||
|
uint8_t progtype;
|
||||||
|
uint8_t parmode;
|
||||||
|
uint8_t polling;
|
||||||
|
uint8_t selftimed;
|
||||||
|
uint8_t lockbytes;
|
||||||
|
uint8_t fusebytes;
|
||||||
|
uint8_t flashpoll;
|
||||||
|
uint16_t eeprompoll;
|
||||||
|
uint16_t pagesize;
|
||||||
|
uint16_t eepromsize;
|
||||||
|
uint32_t flashsize;
|
||||||
|
}
|
||||||
|
parameter;
|
||||||
|
|
||||||
|
parameter param;
|
||||||
|
|
||||||
|
// this provides a heartbeat on pin 9, so you can tell the software is running.
|
||||||
|
uint8_t hbval = 128;
|
||||||
|
int8_t hbdelta = 8;
|
||||||
|
void heartbeat() {
|
||||||
|
static unsigned long last_time = 0;
|
||||||
|
unsigned long now = millis();
|
||||||
|
if ((now - last_time) < 40) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
last_time = now;
|
||||||
|
if (hbval > 192) {
|
||||||
|
hbdelta = -hbdelta;
|
||||||
|
}
|
||||||
|
if (hbval < 32) {
|
||||||
|
hbdelta = -hbdelta;
|
||||||
|
}
|
||||||
|
hbval += hbdelta;
|
||||||
|
analogWrite(LED_HB, hbval);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool rst_active_high;
|
||||||
|
|
||||||
|
void reset_target(bool reset) {
|
||||||
|
digitalWrite(RESET, ((reset && rst_active_high) || (!reset && !rst_active_high)) ? HIGH : LOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop(void) {
|
||||||
|
// is pmode active?
|
||||||
|
if (pmode) {
|
||||||
|
digitalWrite(LED_PMODE, HIGH);
|
||||||
|
} else {
|
||||||
|
digitalWrite(LED_PMODE, LOW);
|
||||||
|
}
|
||||||
|
// is there an error?
|
||||||
|
if (ISPError) {
|
||||||
|
digitalWrite(LED_ERR, HIGH);
|
||||||
|
} else {
|
||||||
|
digitalWrite(LED_ERR, LOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
// light the heartbeat LED
|
||||||
|
heartbeat();
|
||||||
|
if (SERIAL.available()) {
|
||||||
|
avrisp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t getch() {
|
||||||
|
while (!SERIAL.available());
|
||||||
|
return SERIAL.read();
|
||||||
|
}
|
||||||
|
void fill(int n) {
|
||||||
|
for (int x = 0; x < n; x++) {
|
||||||
|
buff[x] = getch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define PTIME 30
|
||||||
|
void pulse(int pin, int times) {
|
||||||
|
do {
|
||||||
|
digitalWrite(pin, HIGH);
|
||||||
|
delay(PTIME);
|
||||||
|
digitalWrite(pin, LOW);
|
||||||
|
delay(PTIME);
|
||||||
|
} while (times--);
|
||||||
|
}
|
||||||
|
|
||||||
|
void prog_lamp(int state) {
|
||||||
|
if (PROG_FLICKER) {
|
||||||
|
digitalWrite(LED_PMODE, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t spi_transaction(uint8_t a, uint8_t b, uint8_t c, uint8_t d) {
|
||||||
|
SPI.transfer(a);
|
||||||
|
SPI.transfer(b);
|
||||||
|
SPI.transfer(c);
|
||||||
|
return SPI.transfer(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
void empty_reply() {
|
||||||
|
if (CRC_EOP == getch()) {
|
||||||
|
SERIAL.print((char)STK_INSYNC);
|
||||||
|
SERIAL.print((char)STK_OK);
|
||||||
|
} else {
|
||||||
|
ISPError++;
|
||||||
|
SERIAL.print((char)STK_NOSYNC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void breply(uint8_t b) {
|
||||||
|
if (CRC_EOP == getch()) {
|
||||||
|
SERIAL.print((char)STK_INSYNC);
|
||||||
|
SERIAL.print((char)b);
|
||||||
|
SERIAL.print((char)STK_OK);
|
||||||
|
} else {
|
||||||
|
ISPError++;
|
||||||
|
SERIAL.print((char)STK_NOSYNC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void get_version(uint8_t c) {
|
||||||
|
switch (c) {
|
||||||
|
case 0x80:
|
||||||
|
breply(HWVER);
|
||||||
|
break;
|
||||||
|
case 0x81:
|
||||||
|
breply(SWMAJ);
|
||||||
|
break;
|
||||||
|
case 0x82:
|
||||||
|
breply(SWMIN);
|
||||||
|
break;
|
||||||
|
case 0x93:
|
||||||
|
breply('S'); // serial programmer
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
breply(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_parameters() {
|
||||||
|
// call this after reading parameter packet into buff[]
|
||||||
|
param.devicecode = buff[0];
|
||||||
|
param.revision = buff[1];
|
||||||
|
param.progtype = buff[2];
|
||||||
|
param.parmode = buff[3];
|
||||||
|
param.polling = buff[4];
|
||||||
|
param.selftimed = buff[5];
|
||||||
|
param.lockbytes = buff[6];
|
||||||
|
param.fusebytes = buff[7];
|
||||||
|
param.flashpoll = buff[8];
|
||||||
|
// ignore buff[9] (= buff[8])
|
||||||
|
// following are 16 bits (big endian)
|
||||||
|
param.eeprompoll = beget16(&buff[10]);
|
||||||
|
param.pagesize = beget16(&buff[12]);
|
||||||
|
param.eepromsize = beget16(&buff[14]);
|
||||||
|
|
||||||
|
// 32 bits flashsize (big endian)
|
||||||
|
param.flashsize = buff[16] * 0x01000000
|
||||||
|
+ buff[17] * 0x00010000
|
||||||
|
+ buff[18] * 0x00000100
|
||||||
|
+ buff[19];
|
||||||
|
|
||||||
|
// AVR devices have active low reset, AT89Sx are active high
|
||||||
|
rst_active_high = (param.devicecode >= 0xe0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void start_pmode() {
|
||||||
|
|
||||||
|
// Reset target before driving PIN_SCK or PIN_MOSI
|
||||||
|
|
||||||
|
// SPI.begin() will configure SS as output, so SPI master mode is selected.
|
||||||
|
// We have defined RESET as pin 10, which for many Arduinos is not the SS pin.
|
||||||
|
// So we have to configure RESET as output here,
|
||||||
|
// (reset_target() first sets the correct level)
|
||||||
|
reset_target(true);
|
||||||
|
pinMode(RESET, OUTPUT);
|
||||||
|
SPI.begin();
|
||||||
|
SPI.beginTransaction(SPISettings(SPI_CLOCK, MSBFIRST, SPI_MODE0));
|
||||||
|
|
||||||
|
// See AVR datasheets, chapter "SERIAL_PRG Programming Algorithm":
|
||||||
|
|
||||||
|
// Pulse RESET after PIN_SCK is low:
|
||||||
|
digitalWrite(PIN_SCK, LOW);
|
||||||
|
delay(20); // discharge PIN_SCK, value arbitrarily chosen
|
||||||
|
reset_target(false);
|
||||||
|
// Pulse must be minimum 2 target CPU clock cycles so 100 usec is ok for CPU
|
||||||
|
// speeds above 20 KHz
|
||||||
|
delayMicroseconds(100);
|
||||||
|
reset_target(true);
|
||||||
|
|
||||||
|
// Send the enable programming command:
|
||||||
|
delay(50); // datasheet: must be > 20 msec
|
||||||
|
spi_transaction(0xAC, 0x53, 0x00, 0x00);
|
||||||
|
pmode = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void end_pmode() {
|
||||||
|
SPI.end();
|
||||||
|
// We're about to take the target out of reset so configure SPI pins as input
|
||||||
|
pinMode(PIN_MOSI, INPUT);
|
||||||
|
pinMode(PIN_SCK, INPUT);
|
||||||
|
reset_target(false);
|
||||||
|
pinMode(RESET, INPUT);
|
||||||
|
pmode = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void universal() {
|
||||||
|
uint8_t ch;
|
||||||
|
|
||||||
|
fill(4);
|
||||||
|
ch = spi_transaction(buff[0], buff[1], buff[2], buff[3]);
|
||||||
|
breply(ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
void flash(uint8_t hilo, unsigned int addr, uint8_t data) {
|
||||||
|
spi_transaction(0x40 + 8 * hilo,
|
||||||
|
addr >> 8 & 0xFF,
|
||||||
|
addr & 0xFF,
|
||||||
|
data);
|
||||||
|
}
|
||||||
|
void commit(unsigned int addr) {
|
||||||
|
if (PROG_FLICKER) {
|
||||||
|
prog_lamp(LOW);
|
||||||
|
}
|
||||||
|
spi_transaction(0x4C, (addr >> 8) & 0xFF, addr & 0xFF, 0);
|
||||||
|
if (PROG_FLICKER) {
|
||||||
|
delay(PTIME);
|
||||||
|
prog_lamp(HIGH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int current_page() {
|
||||||
|
if (param.pagesize == 32) {
|
||||||
|
return here & 0xFFFFFFF0;
|
||||||
|
}
|
||||||
|
if (param.pagesize == 64) {
|
||||||
|
return here & 0xFFFFFFE0;
|
||||||
|
}
|
||||||
|
if (param.pagesize == 128) {
|
||||||
|
return here & 0xFFFFFFC0;
|
||||||
|
}
|
||||||
|
if (param.pagesize == 256) {
|
||||||
|
return here & 0xFFFFFF80;
|
||||||
|
}
|
||||||
|
return here;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void write_flash(int length) {
|
||||||
|
fill(length);
|
||||||
|
if (CRC_EOP == getch()) {
|
||||||
|
SERIAL.print((char) STK_INSYNC);
|
||||||
|
SERIAL.print((char) write_flash_pages(length));
|
||||||
|
} else {
|
||||||
|
ISPError++;
|
||||||
|
SERIAL.print((char) STK_NOSYNC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t write_flash_pages(int length) {
|
||||||
|
int x = 0;
|
||||||
|
unsigned int page = current_page();
|
||||||
|
while (x < length) {
|
||||||
|
if (page != current_page()) {
|
||||||
|
commit(page);
|
||||||
|
page = current_page();
|
||||||
|
}
|
||||||
|
flash(LOW, here, buff[x++]);
|
||||||
|
flash(HIGH, here, buff[x++]);
|
||||||
|
here++;
|
||||||
|
}
|
||||||
|
|
||||||
|
commit(page);
|
||||||
|
|
||||||
|
return STK_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define EECHUNK (32)
|
||||||
|
uint8_t write_eeprom(unsigned int length) {
|
||||||
|
// here is a word address, get the byte address
|
||||||
|
unsigned int start = here * 2;
|
||||||
|
unsigned int remaining = length;
|
||||||
|
if (length > param.eepromsize) {
|
||||||
|
ISPError++;
|
||||||
|
return STK_FAILED;
|
||||||
|
}
|
||||||
|
while (remaining > EECHUNK) {
|
||||||
|
write_eeprom_chunk(start, EECHUNK);
|
||||||
|
start += EECHUNK;
|
||||||
|
remaining -= EECHUNK;
|
||||||
|
}
|
||||||
|
write_eeprom_chunk(start, remaining);
|
||||||
|
return STK_OK;
|
||||||
|
}
|
||||||
|
// write (length) bytes, (start) is a byte address
|
||||||
|
uint8_t write_eeprom_chunk(unsigned int start, unsigned int length) {
|
||||||
|
// this writes byte-by-byte, page writing may be faster (4 bytes at a time)
|
||||||
|
fill(length);
|
||||||
|
prog_lamp(LOW);
|
||||||
|
for (unsigned int x = 0; x < length; x++) {
|
||||||
|
unsigned int addr = start + x;
|
||||||
|
spi_transaction(0xC0, (addr >> 8) & 0xFF, addr & 0xFF, buff[x]);
|
||||||
|
delay(45);
|
||||||
|
}
|
||||||
|
prog_lamp(HIGH);
|
||||||
|
return STK_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void program_page() {
|
||||||
|
char result = (char) STK_FAILED;
|
||||||
|
unsigned int length = 256 * getch();
|
||||||
|
length += getch();
|
||||||
|
char memtype = getch();
|
||||||
|
// flash memory @here, (length) bytes
|
||||||
|
if (memtype == 'F') {
|
||||||
|
write_flash(length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (memtype == 'E') {
|
||||||
|
result = (char)write_eeprom(length);
|
||||||
|
if (CRC_EOP == getch()) {
|
||||||
|
SERIAL.print((char) STK_INSYNC);
|
||||||
|
SERIAL.print(result);
|
||||||
|
} else {
|
||||||
|
ISPError++;
|
||||||
|
SERIAL.print((char) STK_NOSYNC);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SERIAL.print((char)STK_FAILED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t flash_read(uint8_t hilo, unsigned int addr) {
|
||||||
|
return spi_transaction(0x20 + hilo * 8,
|
||||||
|
(addr >> 8) & 0xFF,
|
||||||
|
addr & 0xFF,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
|
||||||
|
char flash_read_page(int length) {
|
||||||
|
for (int x = 0; x < length; x += 2) {
|
||||||
|
uint8_t low = flash_read(LOW, here);
|
||||||
|
SERIAL.print((char) low);
|
||||||
|
uint8_t high = flash_read(HIGH, here);
|
||||||
|
SERIAL.print((char) high);
|
||||||
|
here++;
|
||||||
|
}
|
||||||
|
return STK_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
char eeprom_read_page(int length) {
|
||||||
|
// here again we have a word address
|
||||||
|
int start = here * 2;
|
||||||
|
for (int x = 0; x < length; x++) {
|
||||||
|
int addr = start + x;
|
||||||
|
uint8_t ee = spi_transaction(0xA0, (addr >> 8) & 0xFF, addr & 0xFF, 0xFF);
|
||||||
|
SERIAL.print((char) ee);
|
||||||
|
}
|
||||||
|
return STK_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void read_page() {
|
||||||
|
char result = (char)STK_FAILED;
|
||||||
|
int length = 256 * getch();
|
||||||
|
length += getch();
|
||||||
|
char memtype = getch();
|
||||||
|
if (CRC_EOP != getch()) {
|
||||||
|
ISPError++;
|
||||||
|
SERIAL.print((char) STK_NOSYNC);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SERIAL.print((char) STK_INSYNC);
|
||||||
|
if (memtype == 'F') {
|
||||||
|
result = flash_read_page(length);
|
||||||
|
}
|
||||||
|
if (memtype == 'E') {
|
||||||
|
result = eeprom_read_page(length);
|
||||||
|
}
|
||||||
|
SERIAL.print(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void read_signature() {
|
||||||
|
if (CRC_EOP != getch()) {
|
||||||
|
ISPError++;
|
||||||
|
SERIAL.print((char) STK_NOSYNC);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SERIAL.print((char) STK_INSYNC);
|
||||||
|
uint8_t high = spi_transaction(0x30, 0x00, 0x00, 0x00);
|
||||||
|
SERIAL.print((char) high);
|
||||||
|
uint8_t middle = spi_transaction(0x30, 0x00, 0x01, 0x00);
|
||||||
|
SERIAL.print((char) middle);
|
||||||
|
uint8_t low = spi_transaction(0x30, 0x00, 0x02, 0x00);
|
||||||
|
SERIAL.print((char) low);
|
||||||
|
SERIAL.print((char) STK_OK);
|
||||||
|
}
|
||||||
|
//////////////////////////////////////////
|
||||||
|
//////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////
|
||||||
|
////////////////////////////////////
|
||||||
|
void avrisp() {
|
||||||
|
uint8_t ch = getch();
|
||||||
|
switch (ch) {
|
||||||
|
case '0': // signon
|
||||||
|
ISPError = 0;
|
||||||
|
empty_reply();
|
||||||
|
break;
|
||||||
|
case '1':
|
||||||
|
if (getch() == CRC_EOP) {
|
||||||
|
SERIAL.print((char) STK_INSYNC);
|
||||||
|
SERIAL.print("AVR ISP");
|
||||||
|
SERIAL.print((char) STK_OK);
|
||||||
|
} else {
|
||||||
|
ISPError++;
|
||||||
|
SERIAL.print((char) STK_NOSYNC);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'A':
|
||||||
|
get_version(getch());
|
||||||
|
break;
|
||||||
|
case 'B':
|
||||||
|
fill(20);
|
||||||
|
set_parameters();
|
||||||
|
empty_reply();
|
||||||
|
break;
|
||||||
|
case 'E': // extended parameters - ignore for now
|
||||||
|
fill(5);
|
||||||
|
empty_reply();
|
||||||
|
break;
|
||||||
|
case 'P':
|
||||||
|
if (!pmode) {
|
||||||
|
start_pmode();
|
||||||
|
}
|
||||||
|
empty_reply();
|
||||||
|
break;
|
||||||
|
case 'U': // set address (word)
|
||||||
|
here = getch();
|
||||||
|
here += 256 * getch();
|
||||||
|
empty_reply();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x60: //STK_PROG_FLASH
|
||||||
|
getch(); // low addr
|
||||||
|
getch(); // high addr
|
||||||
|
empty_reply();
|
||||||
|
break;
|
||||||
|
case 0x61: //STK_PROG_DATA
|
||||||
|
getch(); // data
|
||||||
|
empty_reply();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x64: //STK_PROG_PAGE
|
||||||
|
program_page();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x74: //STK_READ_PAGE 't'
|
||||||
|
read_page();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'V': //0x56
|
||||||
|
universal();
|
||||||
|
break;
|
||||||
|
case 'Q': //0x51
|
||||||
|
ISPError = 0;
|
||||||
|
end_pmode();
|
||||||
|
empty_reply();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x75: //STK_READ_SIGN 'u'
|
||||||
|
read_signature();
|
||||||
|
break;
|
||||||
|
|
||||||
|
// expecting a command, not CRC_EOP
|
||||||
|
// this is how we can get back in sync
|
||||||
|
case CRC_EOP:
|
||||||
|
ISPError++;
|
||||||
|
SERIAL.print((char) STK_NOSYNC);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// anything else we will return STK_UNKNOWN
|
||||||
|
default:
|
||||||
|
ISPError++;
|
||||||
|
if (CRC_EOP == getch()) {
|
||||||
|
SERIAL.print((char)STK_UNKNOWN);
|
||||||
|
} else {
|
||||||
|
SERIAL.print((char)STK_NOSYNC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
@@ -1,15 +1,21 @@
|
|||||||
{
|
{
|
||||||
"board": {
|
"board": {
|
||||||
|
"3dviewports": [],
|
||||||
"design_settings": {
|
"design_settings": {
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"board_outline_line_width": 0.09999999999999999,
|
"apply_defaults_to_fp_barcodes": false,
|
||||||
"copper_line_width": 0.19999999999999998,
|
"apply_defaults_to_fp_dimensions": false,
|
||||||
|
"apply_defaults_to_fp_fields": false,
|
||||||
|
"apply_defaults_to_fp_shapes": false,
|
||||||
|
"apply_defaults_to_fp_text": false,
|
||||||
|
"board_outline_line_width": 0.1,
|
||||||
|
"copper_line_width": 0.2,
|
||||||
"copper_text_italic": false,
|
"copper_text_italic": false,
|
||||||
"copper_text_size_h": 1.5,
|
"copper_text_size_h": 1.5,
|
||||||
"copper_text_size_v": 1.5,
|
"copper_text_size_v": 1.5,
|
||||||
"copper_text_thickness": 0.3,
|
"copper_text_thickness": 0.3,
|
||||||
"copper_text_upright": false,
|
"copper_text_upright": false,
|
||||||
"courtyard_line_width": 0.049999999999999996,
|
"courtyard_line_width": 0.05,
|
||||||
"dimension_precision": 4,
|
"dimension_precision": 4,
|
||||||
"dimension_units": 3,
|
"dimension_units": 3,
|
||||||
"dimensions": {
|
"dimensions": {
|
||||||
@@ -20,7 +26,7 @@
|
|||||||
"text_position": 0,
|
"text_position": 0,
|
||||||
"units_format": 1
|
"units_format": 1
|
||||||
},
|
},
|
||||||
"fab_line_width": 0.09999999999999999,
|
"fab_line_width": 0.1,
|
||||||
"fab_text_italic": false,
|
"fab_text_italic": false,
|
||||||
"fab_text_size_h": 1.0,
|
"fab_text_size_h": 1.0,
|
||||||
"fab_text_size_v": 1.0,
|
"fab_text_size_v": 1.0,
|
||||||
@@ -45,7 +51,7 @@
|
|||||||
"silk_text_upright": false,
|
"silk_text_upright": false,
|
||||||
"zones": {
|
"zones": {
|
||||||
"45_degree_only": false,
|
"45_degree_only": false,
|
||||||
"min_clearance": 0.19999999999999998
|
"min_clearance": 0.2
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"diff_pair_dimensions": [
|
"diff_pair_dimensions": [
|
||||||
@@ -62,35 +68,63 @@
|
|||||||
"rule_severities": {
|
"rule_severities": {
|
||||||
"annular_width": "error",
|
"annular_width": "error",
|
||||||
"clearance": "error",
|
"clearance": "error",
|
||||||
|
"connection_width": "warning",
|
||||||
"copper_edge_clearance": "error",
|
"copper_edge_clearance": "error",
|
||||||
|
"copper_sliver": "warning",
|
||||||
"courtyards_overlap": "error",
|
"courtyards_overlap": "error",
|
||||||
|
"creepage": "error",
|
||||||
"diff_pair_gap_out_of_range": "error",
|
"diff_pair_gap_out_of_range": "error",
|
||||||
"diff_pair_uncoupled_length_too_long": "error",
|
"diff_pair_uncoupled_length_too_long": "error",
|
||||||
"drill_out_of_range": "error",
|
"drill_out_of_range": "error",
|
||||||
"duplicate_footprints": "warning",
|
"duplicate_footprints": "warning",
|
||||||
"extra_footprint": "warning",
|
"extra_footprint": "warning",
|
||||||
|
"footprint": "error",
|
||||||
|
"footprint_filters_mismatch": "ignore",
|
||||||
|
"footprint_symbol_field_mismatch": "warning",
|
||||||
|
"footprint_symbol_mismatch": "warning",
|
||||||
|
"footprint_type_mismatch": "ignore",
|
||||||
"hole_clearance": "error",
|
"hole_clearance": "error",
|
||||||
"hole_near_hole": "error",
|
"hole_near_hole": "error",
|
||||||
|
"hole_to_hole": "error",
|
||||||
|
"holes_co_located": "warning",
|
||||||
"invalid_outline": "error",
|
"invalid_outline": "error",
|
||||||
|
"isolated_copper": "warning",
|
||||||
"item_on_disabled_layer": "error",
|
"item_on_disabled_layer": "error",
|
||||||
"items_not_allowed": "error",
|
"items_not_allowed": "error",
|
||||||
"length_out_of_range": "error",
|
"length_out_of_range": "error",
|
||||||
|
"lib_footprint_issues": "warning",
|
||||||
|
"lib_footprint_mismatch": "warning",
|
||||||
"malformed_courtyard": "error",
|
"malformed_courtyard": "error",
|
||||||
"microvia_drill_out_of_range": "error",
|
"microvia_drill_out_of_range": "error",
|
||||||
|
"mirrored_text_on_front_layer": "warning",
|
||||||
"missing_courtyard": "ignore",
|
"missing_courtyard": "ignore",
|
||||||
"missing_footprint": "warning",
|
"missing_footprint": "warning",
|
||||||
|
"missing_tuning_profile": "warning",
|
||||||
"net_conflict": "warning",
|
"net_conflict": "warning",
|
||||||
|
"nonmirrored_text_on_back_layer": "warning",
|
||||||
"npth_inside_courtyard": "ignore",
|
"npth_inside_courtyard": "ignore",
|
||||||
"padstack": "error",
|
"padstack": "error",
|
||||||
"pth_inside_courtyard": "ignore",
|
"pth_inside_courtyard": "ignore",
|
||||||
"shorting_items": "error",
|
"shorting_items": "error",
|
||||||
|
"silk_edge_clearance": "warning",
|
||||||
"silk_over_copper": "error",
|
"silk_over_copper": "error",
|
||||||
"silk_overlap": "error",
|
"silk_overlap": "error",
|
||||||
"skew_out_of_range": "error",
|
"skew_out_of_range": "error",
|
||||||
|
"solder_mask_bridge": "error",
|
||||||
|
"starved_thermal": "error",
|
||||||
|
"text_height": "warning",
|
||||||
|
"text_on_edge_cuts": "error",
|
||||||
|
"text_thickness": "warning",
|
||||||
|
"through_hole_pad_without_hole": "error",
|
||||||
"too_many_vias": "error",
|
"too_many_vias": "error",
|
||||||
|
"track_angle": "error",
|
||||||
"track_dangling": "warning",
|
"track_dangling": "warning",
|
||||||
|
"track_not_centered_on_via": "ignore",
|
||||||
|
"track_on_post_machined_layer": "error",
|
||||||
|
"track_segment_length": "error",
|
||||||
"track_width": "error",
|
"track_width": "error",
|
||||||
"tracks_crossing": "error",
|
"tracks_crossing": "error",
|
||||||
|
"tuning_profile_track_geometries": "ignore",
|
||||||
"unconnected_items": "error",
|
"unconnected_items": "error",
|
||||||
"unresolved_variable": "error",
|
"unresolved_variable": "error",
|
||||||
"via_dangling": "warning",
|
"via_dangling": "warning",
|
||||||
@@ -102,22 +136,99 @@
|
|||||||
"allow_microvias": false,
|
"allow_microvias": false,
|
||||||
"max_error": 0.005,
|
"max_error": 0.005,
|
||||||
"min_clearance": 0.15,
|
"min_clearance": 0.15,
|
||||||
"min_copper_edge_clearance": 0.049999999999999996,
|
"min_connection": 0.0,
|
||||||
|
"min_copper_edge_clearance": 0.05,
|
||||||
|
"min_groove_width": 0.0,
|
||||||
"min_hole_clearance": 0.0,
|
"min_hole_clearance": 0.0,
|
||||||
"min_hole_to_hole": 0.25,
|
"min_hole_to_hole": 0.25,
|
||||||
"min_microvia_diameter": 0.19999999999999998,
|
"min_microvia_diameter": 0.2,
|
||||||
"min_microvia_drill": 0.09999999999999999,
|
"min_microvia_drill": 0.1,
|
||||||
|
"min_resolved_spokes": 2,
|
||||||
"min_silk_clearance": 0.0,
|
"min_silk_clearance": 0.0,
|
||||||
"min_through_hole_diameter": 0.19999999999999998,
|
"min_text_height": 0.8,
|
||||||
|
"min_text_thickness": 0.08,
|
||||||
|
"min_through_hole_diameter": 0.2,
|
||||||
"min_track_width": 0.15,
|
"min_track_width": 0.15,
|
||||||
"min_via_annular_width": 0.049999999999999996,
|
"min_via_annular_width": 0.05,
|
||||||
"min_via_diameter": 0.19999999999999998
|
"min_via_diameter": 0.2,
|
||||||
|
"solder_mask_to_copper_clearance": 0.0,
|
||||||
|
"use_height_for_length_calcs": true
|
||||||
},
|
},
|
||||||
|
"teardrop_options": [
|
||||||
|
{
|
||||||
|
"td_onpthpad": true,
|
||||||
|
"td_onroundshapesonly": false,
|
||||||
|
"td_onsmdpad": true,
|
||||||
|
"td_ontrackend": false,
|
||||||
|
"td_onvia": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"teardrop_parameters": [
|
||||||
|
{
|
||||||
|
"td_allow_use_two_tracks": true,
|
||||||
|
"td_curve_segcount": 0,
|
||||||
|
"td_height_ratio": 1.0,
|
||||||
|
"td_length_ratio": 0.5,
|
||||||
|
"td_maxheight": 2.0,
|
||||||
|
"td_maxlen": 1.0,
|
||||||
|
"td_on_pad_in_zone": false,
|
||||||
|
"td_target_name": "td_round_shape",
|
||||||
|
"td_width_to_size_filter_ratio": 0.9
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"td_allow_use_two_tracks": true,
|
||||||
|
"td_curve_segcount": 0,
|
||||||
|
"td_height_ratio": 1.0,
|
||||||
|
"td_length_ratio": 0.5,
|
||||||
|
"td_maxheight": 2.0,
|
||||||
|
"td_maxlen": 1.0,
|
||||||
|
"td_on_pad_in_zone": false,
|
||||||
|
"td_target_name": "td_rect_shape",
|
||||||
|
"td_width_to_size_filter_ratio": 0.9
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"td_allow_use_two_tracks": true,
|
||||||
|
"td_curve_segcount": 0,
|
||||||
|
"td_height_ratio": 1.0,
|
||||||
|
"td_length_ratio": 0.5,
|
||||||
|
"td_maxheight": 2.0,
|
||||||
|
"td_maxlen": 1.0,
|
||||||
|
"td_on_pad_in_zone": false,
|
||||||
|
"td_target_name": "td_track_end",
|
||||||
|
"td_width_to_size_filter_ratio": 0.9
|
||||||
|
}
|
||||||
|
],
|
||||||
"track_widths": [
|
"track_widths": [
|
||||||
0.0,
|
0.0,
|
||||||
0.15,
|
0.15,
|
||||||
0.2
|
0.2
|
||||||
],
|
],
|
||||||
|
"tuning_pattern_settings": {
|
||||||
|
"diff_pair_defaults": {
|
||||||
|
"corner_radius_percentage": 80,
|
||||||
|
"corner_style": 1,
|
||||||
|
"max_amplitude": 1.0,
|
||||||
|
"min_amplitude": 0.2,
|
||||||
|
"single_sided": false,
|
||||||
|
"spacing": 1.0
|
||||||
|
},
|
||||||
|
"diff_pair_skew_defaults": {
|
||||||
|
"corner_radius_percentage": 80,
|
||||||
|
"corner_style": 1,
|
||||||
|
"max_amplitude": 1.0,
|
||||||
|
"min_amplitude": 0.2,
|
||||||
|
"single_sided": false,
|
||||||
|
"spacing": 0.6
|
||||||
|
},
|
||||||
|
"single_track_defaults": {
|
||||||
|
"corner_radius_percentage": 80,
|
||||||
|
"corner_style": 1,
|
||||||
|
"max_amplitude": 1.0,
|
||||||
|
"min_amplitude": 0.2,
|
||||||
|
"single_sided": false,
|
||||||
|
"spacing": 0.6
|
||||||
|
}
|
||||||
|
},
|
||||||
"via_dimensions": [
|
"via_dimensions": [
|
||||||
{
|
{
|
||||||
"diameter": 0.0,
|
"diameter": 0.0,
|
||||||
@@ -127,9 +238,29 @@
|
|||||||
"zones_allow_external_fillets": false,
|
"zones_allow_external_fillets": false,
|
||||||
"zones_use_no_outline": true
|
"zones_use_no_outline": true
|
||||||
},
|
},
|
||||||
"layer_presets": []
|
"ipc2581": {
|
||||||
|
"bom_rev": "",
|
||||||
|
"dist": "",
|
||||||
|
"distpn": "",
|
||||||
|
"internal_id": "",
|
||||||
|
"mfg": "",
|
||||||
|
"mpn": "",
|
||||||
|
"sch_revision": ""
|
||||||
|
},
|
||||||
|
"layer_pairs": [],
|
||||||
|
"layer_presets": [],
|
||||||
|
"viewports": []
|
||||||
},
|
},
|
||||||
"boards": [],
|
"boards": [],
|
||||||
|
"component_class_settings": {
|
||||||
|
"assignments": [],
|
||||||
|
"meta": {
|
||||||
|
"version": 0
|
||||||
|
},
|
||||||
|
"sheet_component_classes": {
|
||||||
|
"enabled": false
|
||||||
|
}
|
||||||
|
},
|
||||||
"cvpcb": {
|
"cvpcb": {
|
||||||
"equivalence_files": []
|
"equivalence_files": []
|
||||||
},
|
},
|
||||||
@@ -310,6 +441,7 @@
|
|||||||
],
|
],
|
||||||
"rule_severities": {
|
"rule_severities": {
|
||||||
"bus_definition_conflict": "error",
|
"bus_definition_conflict": "error",
|
||||||
|
"bus_entry_needed": "error",
|
||||||
"bus_label_syntax": "error",
|
"bus_label_syntax": "error",
|
||||||
"bus_to_bus_conflict": "error",
|
"bus_to_bus_conflict": "error",
|
||||||
"bus_to_net_conflict": "error",
|
"bus_to_net_conflict": "error",
|
||||||
@@ -317,11 +449,24 @@
|
|||||||
"different_unit_net": "error",
|
"different_unit_net": "error",
|
||||||
"duplicate_reference": "error",
|
"duplicate_reference": "error",
|
||||||
"duplicate_sheet_names": "error",
|
"duplicate_sheet_names": "error",
|
||||||
|
"endpoint_off_grid": "warning",
|
||||||
"extra_units": "error",
|
"extra_units": "error",
|
||||||
|
"field_name_whitespace": "warning",
|
||||||
|
"footprint_filter": "ignore",
|
||||||
|
"footprint_link_issues": "warning",
|
||||||
|
"four_way_junction": "ignore",
|
||||||
"global_label_dangling": "warning",
|
"global_label_dangling": "warning",
|
||||||
|
"ground_pin_not_ground": "warning",
|
||||||
"hier_label_mismatch": "error",
|
"hier_label_mismatch": "error",
|
||||||
|
"isolated_pin_label": "warning",
|
||||||
"label_dangling": "error",
|
"label_dangling": "error",
|
||||||
|
"label_multiple_wires": "warning",
|
||||||
"lib_symbol_issues": "warning",
|
"lib_symbol_issues": "warning",
|
||||||
|
"lib_symbol_mismatch": "warning",
|
||||||
|
"missing_bidi_pin": "warning",
|
||||||
|
"missing_input_pin": "warning",
|
||||||
|
"missing_power_pin": "error",
|
||||||
|
"missing_unit": "warning",
|
||||||
"multiple_net_names": "warning",
|
"multiple_net_names": "warning",
|
||||||
"net_not_bus_member": "warning",
|
"net_not_bus_member": "warning",
|
||||||
"no_connect_connected": "warning",
|
"no_connect_connected": "warning",
|
||||||
@@ -330,8 +475,16 @@
|
|||||||
"pin_not_driven": "error",
|
"pin_not_driven": "error",
|
||||||
"pin_to_pin": "warning",
|
"pin_to_pin": "warning",
|
||||||
"power_pin_not_driven": "error",
|
"power_pin_not_driven": "error",
|
||||||
|
"same_local_global_label": "warning",
|
||||||
|
"similar_label_and_power": "warning",
|
||||||
"similar_labels": "warning",
|
"similar_labels": "warning",
|
||||||
|
"similar_power": "warning",
|
||||||
|
"simulation_model_issue": "ignore",
|
||||||
|
"single_global_label": "ignore",
|
||||||
|
"stacked_pin_name": "warning",
|
||||||
"unannotated": "error",
|
"unannotated": "error",
|
||||||
|
"unconnected_wire_endpoint": "warning",
|
||||||
|
"undefined_netclass": "error",
|
||||||
"unit_value_mismatch": "error",
|
"unit_value_mismatch": "error",
|
||||||
"unresolved_variable": "error",
|
"unresolved_variable": "error",
|
||||||
"wire_dangling": "error"
|
"wire_dangling": "error"
|
||||||
@@ -343,12 +496,12 @@
|
|||||||
},
|
},
|
||||||
"meta": {
|
"meta": {
|
||||||
"filename": "PCB_AndroidAuto.kicad_pro",
|
"filename": "PCB_AndroidAuto.kicad_pro",
|
||||||
"version": 1
|
"version": 3
|
||||||
},
|
},
|
||||||
"net_settings": {
|
"net_settings": {
|
||||||
"classes": [
|
"classes": [
|
||||||
{
|
{
|
||||||
"bus_width": 12.0,
|
"bus_width": 12,
|
||||||
"clearance": 0.1,
|
"clearance": 0.1,
|
||||||
"diff_pair_gap": 0.25,
|
"diff_pair_gap": 0.25,
|
||||||
"diff_pair_via_gap": 0.25,
|
"diff_pair_via_gap": 0.25,
|
||||||
@@ -358,14 +511,16 @@
|
|||||||
"microvia_drill": 0.1,
|
"microvia_drill": 0.1,
|
||||||
"name": "Default",
|
"name": "Default",
|
||||||
"pcb_color": "rgba(0, 0, 0, 0.000)",
|
"pcb_color": "rgba(0, 0, 0, 0.000)",
|
||||||
|
"priority": 2147483647,
|
||||||
"schematic_color": "rgba(0, 0, 0, 0.000)",
|
"schematic_color": "rgba(0, 0, 0, 0.000)",
|
||||||
"track_width": 0.2,
|
"track_width": 0.2,
|
||||||
|
"tuning_profile": "",
|
||||||
"via_diameter": 0.6,
|
"via_diameter": 0.6,
|
||||||
"via_drill": 0.3,
|
"via_drill": 0.3,
|
||||||
"wire_width": 6.0
|
"wire_width": 6
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bus_width": 12.0,
|
"bus_width": 12,
|
||||||
"clearance": 0.2,
|
"clearance": 0.2,
|
||||||
"diff_pair_gap": 0.25,
|
"diff_pair_gap": 0.25,
|
||||||
"diff_pair_via_gap": 0.25,
|
"diff_pair_via_gap": 0.25,
|
||||||
@@ -374,18 +529,17 @@
|
|||||||
"microvia_diameter": 0.5,
|
"microvia_diameter": 0.5,
|
||||||
"microvia_drill": 0.1,
|
"microvia_drill": 0.1,
|
||||||
"name": "5V3A",
|
"name": "5V3A",
|
||||||
"nets": [
|
|
||||||
"+5V"
|
|
||||||
],
|
|
||||||
"pcb_color": "rgba(0, 0, 0, 0.000)",
|
"pcb_color": "rgba(0, 0, 0, 0.000)",
|
||||||
|
"priority": 0,
|
||||||
"schematic_color": "rgba(0, 0, 0, 0.000)",
|
"schematic_color": "rgba(0, 0, 0, 0.000)",
|
||||||
"track_width": 1.37,
|
"track_width": 1.37,
|
||||||
|
"tuning_profile": "",
|
||||||
"via_diameter": 0.6,
|
"via_diameter": 0.6,
|
||||||
"via_drill": 0.3,
|
"via_drill": 0.3,
|
||||||
"wire_width": 6.0
|
"wire_width": 6
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bus_width": 12.0,
|
"bus_width": 12,
|
||||||
"clearance": 0.15,
|
"clearance": 0.15,
|
||||||
"diff_pair_gap": 0.25,
|
"diff_pair_gap": 0.25,
|
||||||
"diff_pair_via_gap": 0.25,
|
"diff_pair_via_gap": 0.25,
|
||||||
@@ -394,18 +548,17 @@
|
|||||||
"microvia_diameter": 0.5,
|
"microvia_diameter": 0.5,
|
||||||
"microvia_drill": 0.1,
|
"microvia_drill": 0.1,
|
||||||
"name": "Power",
|
"name": "Power",
|
||||||
"nets": [
|
|
||||||
"+3V3"
|
|
||||||
],
|
|
||||||
"pcb_color": "rgba(0, 0, 0, 0.000)",
|
"pcb_color": "rgba(0, 0, 0, 0.000)",
|
||||||
|
"priority": 1,
|
||||||
"schematic_color": "rgba(0, 0, 0, 0.000)",
|
"schematic_color": "rgba(0, 0, 0, 0.000)",
|
||||||
"track_width": 0.5,
|
"track_width": 0.5,
|
||||||
|
"tuning_profile": "",
|
||||||
"via_diameter": 0.8,
|
"via_diameter": 0.8,
|
||||||
"via_drill": 0.4,
|
"via_drill": 0.4,
|
||||||
"wire_width": 6.0
|
"wire_width": 6
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bus_width": 12.0,
|
"bus_width": 12,
|
||||||
"clearance": 0.1,
|
"clearance": 0.1,
|
||||||
"diff_pair_gap": 0.25,
|
"diff_pair_gap": 0.25,
|
||||||
"diff_pair_via_gap": 0.25,
|
"diff_pair_via_gap": 0.25,
|
||||||
@@ -414,25 +567,38 @@
|
|||||||
"microvia_diameter": 0.5,
|
"microvia_diameter": 0.5,
|
||||||
"microvia_drill": 0.1,
|
"microvia_drill": 0.1,
|
||||||
"name": "smaller",
|
"name": "smaller",
|
||||||
"nets": [],
|
|
||||||
"pcb_color": "rgba(0, 0, 0, 0.000)",
|
"pcb_color": "rgba(0, 0, 0, 0.000)",
|
||||||
|
"priority": 2,
|
||||||
"schematic_color": "rgba(0, 0, 0, 0.000)",
|
"schematic_color": "rgba(0, 0, 0, 0.000)",
|
||||||
"track_width": 0.15,
|
"track_width": 0.15,
|
||||||
|
"tuning_profile": "",
|
||||||
"via_diameter": 0.5,
|
"via_diameter": 0.5,
|
||||||
"via_drill": 0.4,
|
"via_drill": 0.4,
|
||||||
"wire_width": 6.0
|
"wire_width": 6
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"meta": {
|
"meta": {
|
||||||
"version": 0
|
"version": 5
|
||||||
},
|
},
|
||||||
"net_colors": null
|
"net_colors": null,
|
||||||
|
"netclass_assignments": null,
|
||||||
|
"netclass_patterns": [
|
||||||
|
{
|
||||||
|
"netclass": "5V3A",
|
||||||
|
"pattern": "+5V"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"netclass": "Power",
|
||||||
|
"pattern": "+3V3"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"pcbnew": {
|
"pcbnew": {
|
||||||
"last_paths": {
|
"last_paths": {
|
||||||
"gencad": "",
|
"gencad": "",
|
||||||
"idf": "",
|
"idf": "",
|
||||||
"netlist": "",
|
"netlist": "",
|
||||||
|
"plot": "",
|
||||||
"specctra_dsn": "",
|
"specctra_dsn": "",
|
||||||
"step": "3D/PCB_AndroidAuto.stp",
|
"step": "3D/PCB_AndroidAuto.stp",
|
||||||
"vrml": ""
|
"vrml": ""
|
||||||
@@ -440,26 +606,113 @@
|
|||||||
"page_layout_descr_file": ""
|
"page_layout_descr_file": ""
|
||||||
},
|
},
|
||||||
"schematic": {
|
"schematic": {
|
||||||
|
"annotate_start_num": 0,
|
||||||
|
"annotation": {
|
||||||
|
"method": 0,
|
||||||
|
"sort_order": 0
|
||||||
|
},
|
||||||
|
"bom_export_filename": "${PROJECTNAME}.csv",
|
||||||
|
"bom_fmt_presets": [],
|
||||||
|
"bom_fmt_settings": {
|
||||||
|
"field_delimiter": ",",
|
||||||
|
"keep_line_breaks": false,
|
||||||
|
"keep_tabs": false,
|
||||||
|
"name": "CSV",
|
||||||
|
"ref_delimiter": ",",
|
||||||
|
"ref_range_delimiter": "",
|
||||||
|
"string_delimiter": "\""
|
||||||
|
},
|
||||||
|
"bom_presets": [],
|
||||||
|
"bom_settings": {
|
||||||
|
"exclude_dnp": false,
|
||||||
|
"fields_ordered": [
|
||||||
|
{
|
||||||
|
"group_by": false,
|
||||||
|
"label": "Reference",
|
||||||
|
"name": "Reference",
|
||||||
|
"show": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group_by": false,
|
||||||
|
"label": "Qty",
|
||||||
|
"name": "${QUANTITY}",
|
||||||
|
"show": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group_by": true,
|
||||||
|
"label": "Value",
|
||||||
|
"name": "Value",
|
||||||
|
"show": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group_by": true,
|
||||||
|
"label": "DNP",
|
||||||
|
"name": "${DNP}",
|
||||||
|
"show": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group_by": true,
|
||||||
|
"label": "Exclude from BOM",
|
||||||
|
"name": "${EXCLUDE_FROM_BOM}",
|
||||||
|
"show": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group_by": true,
|
||||||
|
"label": "Exclude from Board",
|
||||||
|
"name": "${EXCLUDE_FROM_BOARD}",
|
||||||
|
"show": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group_by": true,
|
||||||
|
"label": "Footprint",
|
||||||
|
"name": "Footprint",
|
||||||
|
"show": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group_by": false,
|
||||||
|
"label": "Datasheet",
|
||||||
|
"name": "Datasheet",
|
||||||
|
"show": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"filter_string": "",
|
||||||
|
"group_symbols": true,
|
||||||
|
"include_excluded_from_bom": true,
|
||||||
|
"name": "Default Editing",
|
||||||
|
"sort_asc": true,
|
||||||
|
"sort_field": "Reference"
|
||||||
|
},
|
||||||
|
"bus_aliases": {},
|
||||||
|
"connection_grid_size": 50.0,
|
||||||
"drawing": {
|
"drawing": {
|
||||||
|
"dashed_lines_dash_length_ratio": 12.0,
|
||||||
|
"dashed_lines_gap_length_ratio": 3.0,
|
||||||
"default_bus_thickness": 12.0,
|
"default_bus_thickness": 12.0,
|
||||||
"default_junction_size": 40.0,
|
"default_junction_size": 40.0,
|
||||||
"default_line_thickness": 6.0,
|
"default_line_thickness": 6.0,
|
||||||
"default_text_size": 50.0,
|
"default_text_size": 50.0,
|
||||||
"default_wire_thickness": 6.0,
|
"default_wire_thickness": 6.0,
|
||||||
"field_names": [],
|
"field_names": [],
|
||||||
|
"hop_over_size_choice": 0,
|
||||||
"intersheets_ref_own_page": false,
|
"intersheets_ref_own_page": false,
|
||||||
"intersheets_ref_prefix": "",
|
"intersheets_ref_prefix": "",
|
||||||
"intersheets_ref_short": false,
|
"intersheets_ref_short": false,
|
||||||
"intersheets_ref_show": false,
|
"intersheets_ref_show": false,
|
||||||
"intersheets_ref_suffix": "",
|
"intersheets_ref_suffix": "",
|
||||||
"junction_size_choice": 3,
|
"junction_size_choice": 3,
|
||||||
|
"label_size_ratio": 0.3,
|
||||||
|
"operating_point_overlay_i_precision": 3,
|
||||||
|
"operating_point_overlay_i_range": "~A",
|
||||||
|
"operating_point_overlay_v_precision": 3,
|
||||||
|
"operating_point_overlay_v_range": "~V",
|
||||||
|
"overbar_offset_ratio": 1.23,
|
||||||
"pin_symbol_size": 25.0,
|
"pin_symbol_size": 25.0,
|
||||||
"text_offset_ratio": 0.3
|
"text_offset_ratio": 0.3
|
||||||
},
|
},
|
||||||
"legacy_lib_dir": "",
|
"legacy_lib_dir": "",
|
||||||
"legacy_lib_list": [],
|
"legacy_lib_list": [],
|
||||||
"meta": {
|
"meta": {
|
||||||
"version": 0
|
"version": 1
|
||||||
},
|
},
|
||||||
"net_format_name": "",
|
"net_format_name": "",
|
||||||
"ngspice": {
|
"ngspice": {
|
||||||
@@ -470,10 +723,20 @@
|
|||||||
},
|
},
|
||||||
"page_layout_descr_file": "",
|
"page_layout_descr_file": "",
|
||||||
"plot_directory": "",
|
"plot_directory": "",
|
||||||
|
"reuse_designators": true,
|
||||||
"spice_adjust_passive_values": false,
|
"spice_adjust_passive_values": false,
|
||||||
"spice_external_command": "spice \"%I\"",
|
"spice_external_command": "spice \"%I\"",
|
||||||
"subpart_first_id": 65,
|
"subpart_first_id": 65,
|
||||||
"subpart_id_separator": 0
|
"subpart_id_separator": 0,
|
||||||
|
"top_level_sheets": [
|
||||||
|
{
|
||||||
|
"filename": "PCB_AndroidAuto.kicad_sch",
|
||||||
|
"name": "PCB_AndroidAuto",
|
||||||
|
"uuid": "00000000-0000-0000-0000-000000000000"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"used_designators": "",
|
||||||
|
"variants": []
|
||||||
},
|
},
|
||||||
"sheets": [
|
"sheets": [
|
||||||
[
|
[
|
||||||
@@ -481,5 +744,11 @@
|
|||||||
""
|
""
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"text_variables": {}
|
"text_variables": {},
|
||||||
|
"tuning_profiles": {
|
||||||
|
"meta": {
|
||||||
|
"version": 0
|
||||||
|
},
|
||||||
|
"tuning_profiles_impedance_geometric": []
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
Photos/system_diagram.png
Normal file
BIN
Photos/system_diagram.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 769 KiB |
@@ -9,3 +9,4 @@ Android-Auto retrofit for Volvo RTI using a Raspberry pi and crankshaft
|
|||||||
|
|
||||||
## Satus:
|
## Satus:
|
||||||
Not working because of the too low resolution of the original screen.
|
Not working because of the too low resolution of the original screen.
|
||||||
|
|
||||||
37
include/README
Normal file
37
include/README
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
This directory is intended for project header files.
|
||||||
|
|
||||||
|
A header file is a file containing C declarations and macro definitions
|
||||||
|
to be shared between several project source files. You request the use of a
|
||||||
|
header file in your project source file (C, C++, etc) located in `src` folder
|
||||||
|
by including it, with the C preprocessing directive `#include'.
|
||||||
|
|
||||||
|
```src/main.c
|
||||||
|
|
||||||
|
#include "header.h"
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Including a header file produces the same results as copying the header file
|
||||||
|
into each source file that needs it. Such copying would be time-consuming
|
||||||
|
and error-prone. With a header file, the related declarations appear
|
||||||
|
in only one place. If they need to be changed, they can be changed in one
|
||||||
|
place, and programs that include the header file will automatically use the
|
||||||
|
new version when next recompiled. The header file eliminates the labor of
|
||||||
|
finding and changing all the copies as well as the risk that a failure to
|
||||||
|
find one copy will result in inconsistencies within a program.
|
||||||
|
|
||||||
|
In C, the convention is to give header files names that end with `.h'.
|
||||||
|
|
||||||
|
Read more about using header files in official GCC documentation:
|
||||||
|
|
||||||
|
* Include Syntax
|
||||||
|
* Include Operation
|
||||||
|
* Once-Only Headers
|
||||||
|
* Computed Includes
|
||||||
|
|
||||||
|
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
||||||
46
lib/README
Normal file
46
lib/README
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
|
||||||
|
This directory is intended for project specific (private) libraries.
|
||||||
|
PlatformIO will compile them to static libraries and link into the executable file.
|
||||||
|
|
||||||
|
The source code of each library should be placed in a separate directory
|
||||||
|
("lib/your_library_name/[Code]").
|
||||||
|
|
||||||
|
For example, see the structure of the following example libraries `Foo` and `Bar`:
|
||||||
|
|
||||||
|
|--lib
|
||||||
|
| |
|
||||||
|
| |--Bar
|
||||||
|
| | |--docs
|
||||||
|
| | |--examples
|
||||||
|
| | |--src
|
||||||
|
| | |- Bar.c
|
||||||
|
| | |- Bar.h
|
||||||
|
| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||||
|
| |
|
||||||
|
| |--Foo
|
||||||
|
| | |- Foo.c
|
||||||
|
| | |- Foo.h
|
||||||
|
| |
|
||||||
|
| |- README --> THIS FILE
|
||||||
|
|
|
||||||
|
|- platformio.ini
|
||||||
|
|--src
|
||||||
|
|- main.c
|
||||||
|
|
||||||
|
Example contents of `src/main.c` using Foo and Bar:
|
||||||
|
```
|
||||||
|
#include <Foo.h>
|
||||||
|
#include <Bar.h>
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
The PlatformIO Library Dependency Finder will find automatically dependent
|
||||||
|
libraries by scanning project source files.
|
||||||
|
|
||||||
|
More information about PlatformIO Library Dependency Finder
|
||||||
|
- https://docs.platformio.org/page/librarymanager/ldf.html
|
||||||
11
test/README
Normal file
11
test/README
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
This directory is intended for PlatformIO Test Runner and project tests.
|
||||||
|
|
||||||
|
Unit Testing is a software testing method by which individual units of
|
||||||
|
source code, sets of one or more MCU program modules together with associated
|
||||||
|
control data, usage procedures, and operating procedures, are tested to
|
||||||
|
determine whether they are fit for use. Unit testing finds problems early
|
||||||
|
in the development cycle.
|
||||||
|
|
||||||
|
More information about PlatformIO Unit Testing:
|
||||||
|
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
|
||||||
Reference in New Issue
Block a user