diff options
-rw-r--r-- | lib/bmp280.c | 160 | ||||
-rw-r--r-- | lib/bmp280.h | 132 | ||||
-rw-r--r-- | usb-bmp280/usb-bmp280.c | 84 | ||||
-rw-r--r-- | usb-spi/Makefile | 7 |
4 files changed, 224 insertions, 159 deletions
diff --git a/lib/bmp280.c b/lib/bmp280.c index 89cf4cf..0519cca 100644 --- a/lib/bmp280.c +++ b/lib/bmp280.c @@ -26,9 +26,6 @@ #include <LUFA/Drivers/Peripheral/SPI.h> #include "bmp280.h" - -int32_t bmp280_t_fine = 0; - void bmp280_cs(bmp280_sensor *sensor, uint8_t select) { if (!select) @@ -37,115 +34,134 @@ void bmp280_cs(bmp280_sensor *sensor, uint8_t select) *(sensor->cs_port) &= ~ _BV(sensor->cs_pin); } -void bmp280_write8(uint8_t reg, uint8_t value) +void bmp280_write8(bmp280_sensor *sensor, uint8_t reg, uint8_t value) { + bmp280_cs(sensor, true); SPI_SendByte(reg & ~0x80); //bit 7 needs to be low for write mode SPI_SendByte(value); + bmp280_cs(sensor, false); } -uint8_t bmp280_read8(uint8_t reg) +uint8_t bmp280_read8(bmp280_sensor *sensor, uint8_t reg) { + bmp280_cs(sensor, true); SPI_SendByte(reg | 0x80); //bit 7 high for read mode - return SPI_ReceiveByte(); + uint8_t value = SPI_ReceiveByte(); + bmp280_cs(sensor, false); + return value; } -uint16_t bmp280_read16(uint8_t reg) +uint16_t bmp280_read16(bmp280_sensor *sensor, uint8_t reg) { uint16_t value = 0; - SPI_SendByte(reg | 0x80); //bit 7 high for read mode - value |= ((uint16_t) SPI_ReceiveByte() & 0xFF) << 8; - value |= (uint16_t) SPI_ReceiveByte() & 0xFF; - return value; + bmp280_cs(sensor, true); + SPI_SendByte(reg | 0x80); //bit 7 high for read mode + value |= ((uint16_t) SPI_ReceiveByte() & 0xFF) << 8; + value |= (uint16_t) SPI_ReceiveByte() & 0xFF; + bmp280_cs(sensor, false); + return value; } -uint32_t bmp280_read24(uint8_t reg) +uint32_t bmp280_read24(bmp280_sensor *sensor, uint8_t reg) { - uint32_t value = 0; - SPI_SendByte(reg | 0x80); //bit 7 high for read mode - value |= ((uint32_t) SPI_ReceiveByte() & 0xFF) << 16; - value |= ((uint32_t) SPI_ReceiveByte() & 0xFF) << 8; - value |= (uint32_t) SPI_ReceiveByte() & 0xFF; - return value; + uint32_t value = 0; + bmp280_cs(sensor, true); + SPI_SendByte(reg | 0x80); //bit 7 high for read mode + value |= ((uint32_t) SPI_ReceiveByte() & 0xFF) << 16; + value |= ((uint32_t) SPI_ReceiveByte() & 0xFF) << 8; + value |= (uint32_t) SPI_ReceiveByte() & 0xFF; + bmp280_cs(sensor, false); + return value; } -int16_t bmp280_readS16(uint8_t reg) +int16_t bmp280_readS16(bmp280_sensor *sensor, uint8_t reg) { - return (int16_t) bmp280_read16(reg); + return (int16_t) bmp280_read16(sensor, reg); } -uint16_t bmp280_read16_LE(uint8_t reg) +uint16_t bmp280_read16_LE(bmp280_sensor *sensor, uint8_t reg) { - uint16_t value = 0; - SPI_SendByte(reg | 0x80); //bit 7 high for read mode - value |= (uint16_t) SPI_ReceiveByte() & 0xFF; - value |= ((uint16_t) SPI_ReceiveByte() & 0xFF) << 8; - return value; + uint16_t value = bmp280_read16(sensor, reg); + return (value >> 8) | (value << 8); } -int16_t bmp280_readS16_LE(uint8_t reg) +int16_t bmp280_readS16_LE(bmp280_sensor *sensor, uint8_t reg) { - return (int16_t)bmp280_read16_LE(reg); + return (int16_t)bmp280_read16_LE(sensor, reg); } void bmp280_readCoefficients(bmp280_sensor *sensor) { - bmp280_cs(sensor, true); - sensor->dig_T1 = bmp280_read16_LE(BMP280_REGISTER_DIG_T1); - sensor->dig_T2 = bmp280_readS16_LE(BMP280_REGISTER_DIG_T2); - sensor->dig_T3 = bmp280_readS16_LE(BMP280_REGISTER_DIG_T3); - sensor->dig_P1 = bmp280_read16_LE(BMP280_REGISTER_DIG_P1); - sensor->dig_P2 = bmp280_readS16_LE(BMP280_REGISTER_DIG_P2); - sensor->dig_P3 = bmp280_readS16_LE(BMP280_REGISTER_DIG_P3); - sensor->dig_P4 = bmp280_readS16_LE(BMP280_REGISTER_DIG_P4); - sensor->dig_P5 = bmp280_readS16_LE(BMP280_REGISTER_DIG_P5); - sensor->dig_P6 = bmp280_readS16_LE(BMP280_REGISTER_DIG_P6); - sensor->dig_P7 = bmp280_readS16_LE(BMP280_REGISTER_DIG_P7); - sensor->dig_P8 = bmp280_readS16_LE(BMP280_REGISTER_DIG_P8); - sensor->dig_P9 = bmp280_readS16_LE(BMP280_REGISTER_DIG_P9); - bmp280_cs(sensor, false); + sensor->dig_T1 = bmp280_read16_LE(sensor,BMP280_REGISTER_DIG_T1); + sensor->dig_T2 = bmp280_readS16_LE(sensor,BMP280_REGISTER_DIG_T2); + sensor->dig_T3 = bmp280_readS16_LE(sensor,BMP280_REGISTER_DIG_T3); + sensor->dig_P1 = bmp280_read16_LE(sensor,BMP280_REGISTER_DIG_P1); + sensor->dig_P2 = bmp280_readS16_LE(sensor,BMP280_REGISTER_DIG_P2); + sensor->dig_P3 = bmp280_readS16_LE(sensor,BMP280_REGISTER_DIG_P3); + sensor->dig_P4 = bmp280_readS16_LE(sensor,BMP280_REGISTER_DIG_P4); + sensor->dig_P5 = bmp280_readS16_LE(sensor,BMP280_REGISTER_DIG_P5); + sensor->dig_P6 = bmp280_readS16_LE(sensor,BMP280_REGISTER_DIG_P6); + sensor->dig_P7 = bmp280_readS16_LE(sensor,BMP280_REGISTER_DIG_P7); + sensor->dig_P8 = bmp280_readS16_LE(sensor,BMP280_REGISTER_DIG_P8); + sensor->dig_P9 = bmp280_readS16_LE(sensor,BMP280_REGISTER_DIG_P9); +} + +uint8_t bmp280_check_chipid(bmp280_sensor *sensor) +{ + uint8_t chip_id = bmp280_read8(sensor, BMP280_REGISTER_CHIPID); + return chip_id == 0x58; } //need to init SPI beforehand -void bmp280_init(bmp280_sensor *sensor, volatile uint8_t *cs_port, uint8_t cs_pin) +uint8_t bmp280_init(bmp280_sensor *sensor, volatile uint8_t *cs_port, uint8_t cs_pin) { memset(sensor,0,sizeof(bmp280_sensor)); sensor->cs_port = cs_port; sensor->cs_pin = cs_pin; + uint8_t sensor_available = bmp280_check_chipid(sensor); + if (!sensor_available) + return sensor_available; //don't talk with chip, it doesn't speak our language bmp280_readCoefficients(sensor); + bmp280_write8(sensor, BMP280_REGISTER_CONTROL, 0x3F); + return sensor_available; } -float bmp280_readTemp(bmp280_sensor *sensor) +int32_t bmp280_readFineTemp(bmp280_sensor *sensor) { int32_t var1, var2; - bmp280_cs(sensor, true); - int32_t adc_T = bmp280_read24(BMP280_REGISTER_TEMPDATA); - bmp280_cs(sensor, false); + int32_t adc_T = bmp280_read24(sensor, BMP280_REGISTER_TEMPDATA); adc_T >>= 4; - var1 = ((((adc_T>>3) - ((int32_t)sensor->dig_T1 <<1))) * - ((int32_t)sensor->dig_T2)) >> 11; + var1 = ((((adc_T>>3) - ((int32_t)sensor->dig_T1 <<1))) * ((int32_t)sensor->dig_T2)) >> 11; + var2 = (((((adc_T>>4) - ((int32_t)sensor->dig_T1)) * ((adc_T>>4) - ((int32_t)sensor->dig_T1))) >> 12) * ((int32_t)sensor->dig_T3)) >> 14; - var2 = (((((adc_T>>4) - ((int32_t)sensor->dig_T1)) * - ((adc_T>>4) - ((int32_t)sensor->dig_T1))) >> 12) * - ((int32_t)sensor->dig_T3)) >> 14; - - bmp280_t_fine = var1 + var2; + return var1 + var2; +} +float bmp280_convertTempToCelsius(int32_t bmp280_t_fine) +{ float T = (bmp280_t_fine * 5 + 128) >> 8; return T/100; } -float bmp280_readPressure(bmp280_sensor *sensor) +float bmp280_readTemp(bmp280_sensor *sensor) { + return bmp280_convertTempToCelsius(bmp280_readFineTemp(sensor)); +} + +bmp280_result bmp280_readTempAndPressure(bmp280_sensor *sensor) +{ + bmp280_result result; + result.temperature = 0; + result.pressure = 0; + int64_t var1, var2, p; - // Must be done first to get the bmp280_t_fine variable - bmp280_readTemp(sensor); + int32_t bmp280_t_fine = bmp280_readFineTemp(sensor); + result.temperature = bmp280_convertTempToCelsius(bmp280_t_fine); - bmp280_cs(sensor, true); - int32_t adc_P = bmp280_read24(BMP280_REGISTER_PRESSUREDATA); - bmp280_cs(sensor, false); + int32_t adc_P = bmp280_read24(sensor, BMP280_REGISTER_PRESSUREDATA); adc_P >>= 4; var1 = ((int64_t)bmp280_t_fine) - 128000; @@ -158,7 +174,7 @@ float bmp280_readPressure(bmp280_sensor *sensor) if (var1 == 0) { - return 0; // avoid exception caused by division by zero + return result; // avoid exception caused by division by zero } p = 1048576 - adc_P; p = (((p<<31) - var2)*3125) / var1; @@ -166,20 +182,26 @@ float bmp280_readPressure(bmp280_sensor *sensor) var2 = (((int64_t)sensor->dig_P8) * p) >> 19; p = ((p + var1 + var2) >> 8) + (((int64_t)sensor->dig_P7)<<4); - return (float)p/256; + result.pressure = (float)p/256; + return result; } -/*float bmp280_readAltitude(bmp280_sensor *sensor, float sealevelp) +float bmp280_readPressure(bmp280_sensor *sensor) { - float altitude; + bmp280_result result = bmp280_readTempAndPressure(sensor); + return result.pressure; +} - float pressure = bmp280_readPressure(sensor); // in Si units for Pascal +float bmp280_calcAltitude(float pressure, float sealevelp) +{ pressure /= 100; + return 44330 * (1.0 - pow(pressure / sealevelp, 0.1903)); +} - altitude = 44330 * (1.0 - pow(pressure / seaLevelhPa, 0.1903)); - - return altitude; -}*/ +float bmp280_readAltitude(bmp280_sensor *sensor, float sealevelp) +{ + return bmp280_calcAltitude(bmp280_readTempAndPressure(sensor).pressure, sealevelp); +} /// Helper Functions diff --git a/lib/bmp280.h b/lib/bmp280.h index 22472e3..fe8435e 100644 --- a/lib/bmp280.h +++ b/lib/bmp280.h @@ -29,78 +29,94 @@ extern "C" { #endif #define BMP280_AVERAGE_SEA_LEVEL_PRESSURE 1013.25 -#define BMP280_LUFA_SPIO_OPTIONS SPI_SPEED_FCPU_DIV_16 | SPI_MODE_MASTER | SPI_ORDER_MSB_FIRST | SPI_SCK_LEAD_RISING | SPI_SAMPLE_LEADING +#define BMP280_LUFA_SPIO_OPTIONS SPI_SPEED_FCPU_DIV_32 | SPI_MODE_MASTER | SPI_ORDER_MSB_FIRST | SPI_SCK_LEAD_RISING | SPI_SAMPLE_LEADING /*========================================================================= - REGISTERS - -----------------------------------------------------------------------*/ - enum - { - BMP280_REGISTER_DIG_T1 = 0x88, - BMP280_REGISTER_DIG_T2 = 0x8A, - BMP280_REGISTER_DIG_T3 = 0x8C, - - BMP280_REGISTER_DIG_P1 = 0x8E, - BMP280_REGISTER_DIG_P2 = 0x90, - BMP280_REGISTER_DIG_P3 = 0x92, - BMP280_REGISTER_DIG_P4 = 0x94, - BMP280_REGISTER_DIG_P5 = 0x96, - BMP280_REGISTER_DIG_P6 = 0x98, - BMP280_REGISTER_DIG_P7 = 0x9A, - BMP280_REGISTER_DIG_P8 = 0x9C, - BMP280_REGISTER_DIG_P9 = 0x9E, - - BMP280_REGISTER_CHIPID = 0xD0, - BMP280_REGISTER_VERSION = 0xD1, - BMP280_REGISTER_SOFTRESET = 0xE0, - - BMP280_REGISTER_CAL26 = 0xE1, // R calibration stored in 0xE1-0xF0 - - BMP280_REGISTER_CONTROL = 0xF4, - BMP280_REGISTER_CONFIG = 0xF5, - BMP280_REGISTER_PRESSUREDATA = 0xF7, - BMP280_REGISTER_TEMPDATA = 0xFA, - }; +REGISTERS +-----------------------------------------------------------------------*/ +enum +{ + BMP280_REGISTER_DIG_T1 = 0x88, + BMP280_REGISTER_DIG_T2 = 0x8A, + BMP280_REGISTER_DIG_T3 = 0x8C, + + BMP280_REGISTER_DIG_P1 = 0x8E, + BMP280_REGISTER_DIG_P2 = 0x90, + BMP280_REGISTER_DIG_P3 = 0x92, + BMP280_REGISTER_DIG_P4 = 0x94, + BMP280_REGISTER_DIG_P5 = 0x96, + BMP280_REGISTER_DIG_P6 = 0x98, + BMP280_REGISTER_DIG_P7 = 0x9A, + BMP280_REGISTER_DIG_P8 = 0x9C, + BMP280_REGISTER_DIG_P9 = 0x9E, + + BMP280_REGISTER_CHIPID = 0xD0, + BMP280_REGISTER_VERSION = 0xD1, + BMP280_REGISTER_SOFTRESET = 0xE0, + + BMP280_REGISTER_CAL26 = 0xE1, // R calibration stored in 0xE1-0xF0 + + BMP280_REGISTER_CONTROL = 0xF4, + BMP280_REGISTER_CONFIG = 0xF5, + BMP280_REGISTER_PRESSUREDATA = 0xF7, + BMP280_REGISTER_TEMPDATA = 0xFA, +}; /*=========================================================================*/ /*========================================================================= - CALIBRATION DATA - -----------------------------------------------------------------------*/ - typedef struct - { - volatile uint8_t *cs_port; - uint8_t cs_pin; - uint16_t dig_T1; - int16_t dig_T2; - int16_t dig_T3; - - uint16_t dig_P1; - int16_t dig_P2; - int16_t dig_P3; - int16_t dig_P4; - int16_t dig_P5; - int16_t dig_P6; - int16_t dig_P7; - int16_t dig_P8; - int16_t dig_P9; - - uint8_t dig_H1; - int16_t dig_H2; - uint8_t dig_H3; - int16_t dig_H4; - int16_t dig_H5; - int8_t dig_H6; - } bmp280_sensor; +CALIBRATION DATA +-----------------------------------------------------------------------*/ +typedef struct +{ + volatile uint8_t *cs_port; + uint8_t cs_pin; + + uint16_t dig_T1; + int16_t dig_T2; + int16_t dig_T3; + + uint16_t dig_P1; + int16_t dig_P2; + int16_t dig_P3; + int16_t dig_P4; + int16_t dig_P5; + int16_t dig_P6; + int16_t dig_P7; + int16_t dig_P8; + int16_t dig_P9; + + uint8_t dig_H1; + int16_t dig_H2; + uint8_t dig_H3; + int16_t dig_H4; + int16_t dig_H5; + int8_t dig_H6; +} bmp280_sensor; /*=========================================================================*/ +typedef struct +{ + float temperature; + float pressure; +} bmp280_result; + //make sure to configure the cs_pin as OUTPUT beforehand //make sure to configure SPI beforehand -void bmp280_init(bmp280_sensor *sensor, volatile uint8_t *cs_port, uint8_t cs_pin); +uint8_t bmp280_init(bmp280_sensor *sensor, volatile uint8_t *cs_port, uint8_t cs_pin); +//check if we deal with am bmp280 chip +uint8_t bmp280_check_chipid(bmp280_sensor *sensor); +//returns temperature in degress celsius float bmp280_readTemp(bmp280_sensor *sensor); +//returns ambient pressure in pascal float bmp280_readPressure(bmp280_sensor *sensor); +//read Temperature and Pressure in one fell swoop +bmp280_result bmp280_readTempAndPressure(bmp280_sensor *sensor); +//calculate altitude from measured pressure and given sealevel-pressure +float bmp280_calcAltitude(float pressure, float sealevelp); +//readPressure and calculate altitude float bmp280_readAltitude(bmp280_sensor *sensor, float sealevelp); diff --git a/usb-bmp280/usb-bmp280.c b/usb-bmp280/usb-bmp280.c index 0c19545..da9c994 100644 --- a/usb-bmp280/usb-bmp280.c +++ b/usb-bmp280/usb-bmp280.c @@ -36,7 +36,7 @@ #include "usbio.h" #include "bmp280.h" -#define ALTITUDE 353.0 // Altitude of Graz in Austria +#define ALTITUDE_GRAZ 353.0 // Altitude of Graz in Austria #define PIN_CS_S0 PD1 #define REG_CS_S0 PIND @@ -47,7 +47,8 @@ #define OP_CLEARBIT &= ~ #define OP_CHECK & #define PIN_SW(PORTDDRREG, PIN, OP) PORTDDRREG OP (1 << PIN) - +#define PINMODE_OUTPUT(REG, PIN) *(®+1) |= (1 << PIN) //just use DDR instead of PORT +#define PINMODE_INPUT(REG, PIN) *(®+1) &= ~(1 << PIN) //just use DDR instead of PORT #define PINREG(x) x #define DDRREG(x) *(&x+1) #define PORTREG(x) *(&x+2) @@ -59,13 +60,21 @@ #define CS_SENSOR_1(LOWHIGH) (PIN_SW(PORTREG(REG_CS_S1),PIN_CS_S1,LOWHIGH)) #define CS_SENSOR(x,LOWHIGH) CS_SENSOR_##x(LOWHIGH) +/* +=== Our Coefficients === +T1: 28483, T2: 26628, T3: 50 +P1: 37848, P2: -10585, P3: 3024, P4: 9882, P5: -217, P6: -7, P7: 15500, P8: -14600, P9: 6000 + +=== Adafruit Arduino Reference Coefficients === +T1: 28483, T2: 26628, T3: 50 +P1: 37848, P2: -10585, P3: 3024, P4: 9882, P5: -217, P6: -7, P7: 15500, P8: -14600, P9: 6000 +*/ + void printCoeffs(bmp280_sensor *sensor) { - printf("Coeffients\r\n"); - printf("T1: %d, T2: %d, T3: %d\r\n", sensor->dig_T1, sensor->dig_T2, sensor->dig_T3); - printf("P1: %d, P2: %d, P3: %d, P4: %d, P5: %d, P6: %d, P7: %d, P8: %d, P9: %d\r\n",sensor->dig_P1,sensor->dig_P2,sensor->dig_P3,sensor->dig_P4,sensor->dig_P5,sensor->dig_P6,sensor->dig_P7,sensor->dig_P8,sensor->dig_P9); - printf("H1: %d, H2: %d, H3: %d, H4: %d, H5: %d, H6: %d\r\n",sensor->dig_H1,sensor->dig_H2,sensor->dig_H3 - ,sensor->dig_H4,sensor->dig_H5,sensor->dig_H6); + printf("T1: %u, T2: %d, T3: %d\r\n", sensor->dig_T1, sensor->dig_T2, sensor->dig_T3); + printf("P1: %u, P2: %d, P3: %d, P4: %d, P5: %d, P6: %d, P7: %d, P8: %d, P9: %d\r\n",sensor->dig_P1,sensor->dig_P2,sensor->dig_P3,sensor->dig_P4,sensor->dig_P5,sensor->dig_P6,sensor->dig_P7,sensor->dig_P8,sensor->dig_P9); + //printf("H1: %d, H2: %d, H3: %d, H4: %d, H5: %d, H6: %d\r\n",sensor->dig_H1,sensor->dig_H2,sensor->dig_H3,sensor->dig_H4,sensor->dig_H5,sensor->dig_H6); } int main(void) @@ -81,40 +90,53 @@ int main(void) bmp280_sensor sensor0; bmp280_sensor sensor1; + uint8_t sensor0_available = 0; + uint8_t sensor1_available = 0; + + //CS Output + PINMODE_OUTPUT(REG_CS_S0,PIN_CS_S0); + PINMODE_OUTPUT(REG_CS_S1,PIN_CS_S1); + //CS High CS_SENSOR(0,HIGHv); CS_SENSOR(1,HIGHv); SPI_Init(BMP280_LUFA_SPIO_OPTIONS); - bmp280_init(&sensor0, &PORTREG(REG_CS_S0), PIN_CS_S0); - bmp280_init(&sensor1, &PORTREG(REG_CS_S1), PIN_CS_S1); - - printf("BMP280 initialized"); + printf("USB-SPI-BMP280 starting"); + + bmp280_result tmppres; + float altitude; + for(;;) { - printf("\r\n== Sensor 0 ==\r\n"); - printCoeffs(&sensor0); - float temp = bmp280_readTemp(&sensor0); - float pressure = bmp280_readPressure(&sensor0); - printf("\r\nPressure: %.2f Pa @ %.2f degC\r\n", pressure, temp); + if (sensor0_available) + { + printCoeffs(&sensor0); + tmppres = bmp280_readTempAndPressure(&sensor0); + altitude = bmp280_calcAltitude(tmppres.pressure, BMP280_AVERAGE_SEA_LEVEL_PRESSURE); + printf("\r\nPressure: %.2f Pa @ %.2f degC\r\n", tmppres.pressure, tmppres.temperature); + printf("Altitude: %.2fm (guessing)\r\n", altitude); + sensor0_available = bmp280_check_chipid(&sensor0); + } else { + printf(" not available\r\n"); + sensor0_available = bmp280_init(&sensor0, &PORTREG(REG_CS_S0), PIN_CS_S0); + } printf("\r\n== Sensor 1 ==\r\n"); - printCoeffs(&sensor1); - temp = bmp280_readTemp(&sensor1); - pressure = bmp280_readPressure(&sensor1); - printf("\r\nPressure: %.2f Pa @ %.2f degC\r\n", pressure, temp); + if (sensor1_available) + { + printCoeffs(&sensor1); + tmppres = bmp280_readTempAndPressure(&sensor1); + altitude = bmp280_calcAltitude(tmppres.pressure, BMP280_AVERAGE_SEA_LEVEL_PRESSURE); + printf("\r\nPressure: %.2f Pa @ %.2f degC\r\n", tmppres.pressure, tmppres.temperature); + printf("Altitude: %.2fm (approximate)\r\n", altitude); + sensor1_available = bmp280_check_chipid(&sensor1); + } else { + printf(" not available\r\n"); + sensor1_available = bmp280_init(&sensor1, &PORTREG(REG_CS_S1), PIN_CS_S1); + } usbio_task(); - int16_t BytesReceived = usbio_bytes_received(); - while(BytesReceived > 0) { - int ReceivedByte = fgetc(stdin); - if(ReceivedByte != EOF) { - if (ReceivedByte == '!') - reset2bootloader(); - } - BytesReceived--; - } - - _delay_ms(2000); // Pause for 5 seconds. + _delay_ms(3000); // Pause for 5 seconds. } } diff --git a/usb-spi/Makefile b/usb-spi/Makefile index 5e9b2c3..27ff005 100644 --- a/usb-spi/Makefile +++ b/usb-spi/Makefile @@ -21,7 +21,7 @@ ## NAME := usb-spi -BOARD_TYPE := teensy2 +BOARD_TYPE := arduinoProMicro OBJ := $(NAME).o LIBS := util led lufa-descriptor-usbserial EXTERNAL_LIBS := lufa @@ -43,3 +43,8 @@ LUFA_OPTS += -D USB_PRODUCT="L\"spreadspace usb-spi example\"" LUFA_COMPONENTS := USB USBCLASS include $(SPREADAVR_PATH)/include.mk + +LDFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm +AVRDUDE_PORT := $(shell $(SPREADAVR_PATH)/tools/detect_newest_acm) +#AVRDUDE_PORT := $(shell $(SPREADAVR_PATH)/tools/detect_lufa_cdc 1) +RESET_FUNC := $(SPREADAVR_PATH)/tools/reset_sparkfun |