working version with SPI w/o blinking

This commit is contained in:
Thomas von Dein
2020-02-29 16:30:00 +01:00
parent 66206eea01
commit 388b17763f
6 changed files with 155 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile
# attiny841:
# BOARD_TAG = attinyx41
# BOARD_SUB = 841
# attiny861:
# BOARD_TAG = attinyx61
# BOARD_SUB = 861
# attiny85:
# BOARD_TAG = attinyx5
# BOARD_SUB = 85
# attiny84:
# BOARD_TAG = attinyx4
# BOARD_SUB = 84
ARDUINO_VERSION = 10810
PROJECT_DIR = $(shell pwd)
BOARD_TAG = attinyx41
BOARD_SUB = 841
ARDUINO_DIR = /usr/local/arduino
ARDMK_DIR = /usr/local/arduino/Arduino-Makefile
MONITOR_PORT = /dev/ttyACM0
ISP_PORT = /dev/ttyACM0
AVRDUDE = /usr/local/bin/avrdude
ARDUINO_LIBS = SPI TinyBME280
ARDUINO_SKETCHBOOK = .
# mk stuff
ALTERNATE_CORE = ATTinyCore
F_CPU = 8000000L
MONITOR_BAUDRATE = 115200
AVRDUDE_ARD_PROGRAMMER = stk500v2
AVRDUDE_ARD_BAUDRATE = 9600
AVR_TOOLS_DIR = /usr/local/avr
AVRDUDE_CONF = /usr/local/etc/avrdude.conf
# Micronucleus
MNINST = sudo micronucleus
# compiler stuff
CFLAGS_STD = -std=gnu11
CXXFLAGS_STD = -std=gnu++11
CXXFLAGS + = -pedantic -Wall -Wextra
CURRENT_DIR = $(shell pwd)
# keep this!
include $(ARDMK_DIR)/Arduino.mk
# install using micronucleus
install: $(TARGET_HEX) verify_size
@echo "########### Press RESET on the Nanite! ##############"
$(MNINST) $(TARGET_HEX)

View File

@@ -0,0 +1,17 @@
# Usable Pins
```
PIN_A0 (10)
PIN_A1 ( 9)
PIN_A2 ( 8)
PIN_A3 ( 7)
PIN_A4 ( 6)
PIN_A5 ( 5)
PIN_A6 ( 4)
PIN_A7 ( 3)
PIN_B0 ( 0)
PIN_B1 ( 1)
PIN_B2 ( 2)
PIN_B3 (11) /* RESET */
LED_BUILTIN (2)
```

View File

@@ -0,0 +1,82 @@
/* -*-c++-*-
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
/*
./hardware/ATTinyCore/avr/cores/tinymodern/core_pins.h
Caution: reverse Pinout: PA3 => Pin 3
Nanite841 Pinout from above:
button
SDO/MISO PA5 PA6 SDI/MOSI
SCK PA4 PA7
CS PA3 PB2
RX0 PA2 PB2
TX0 PA1 PB1
PA0 PB0
GND VCC
usb
Bosch BME280 Breakout from above pin header left:
VCC
GND
SCL => SCK
SDI => MOSI
CSB => PA3/3
SDO => MISO
*/
#define TINY_BME280_SPI
#include <TinyBME280.h>
#define LED LED_BUILTIN
#define CS 3
tiny::BME280 sensor;
uint32_t pres, humidity;
int32_t temp;
void print_measurements() {
temp = sensor.readFixedTempC();
humidity = sensor.readFixedHumidity();
pres = sensor.readFixedPressure();
Serial.print(" Temperature: ");
Serial.print(temp / 100.0);
Serial.println(" Grad C");
Serial.print(" Pressure: ");
Serial.print(pres / 100.0);
Serial.println(" hPa");
Serial.print(" Humidity: ");
Serial.print(humidity / 1000.0);
Serial.println(" %");
Serial.println();
}
void halt() {
while(1);
}
void setup() {
pinMode(LED, OUTPUT);
Serial.begin(115200);
Serial.println("init");
howlong = 500;
if(sensor.beginSPI(CS) == false) {
Serial.println("Sensor BME280 connect failed, check wiring!");
halt();
}
}
void loop() {
print_measurements();
delay(2000);
}

View File

@@ -0,0 +1 @@
/usr/local/arduino/hardware

View File

@@ -0,0 +1 @@
/usr/local/arduino/hardware/ATTinyCore/avr/libraries/SPI

Submodule 841-tinycore-micronucleus-bme280-spi-test/libraries/TinyBME280 added at 87e0b2959c