mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 03:39:49 +03:00
noSerial option, DHT fix, 8266 slim to fit Sonoff
This commit is contained in:
1
compiled/Mega2560-optiboot/upload.bat
Normal file
1
compiled/Mega2560-optiboot/upload.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
..\tools\win\tool-avrdude\avrdude -C ../tools/mac/tool-avrdude/avrdude.conf -v -V -P com8 -patmega2560 -cwiring -b115200 -D -Uflash:w:firmware.hex:i
|
||||||
1
compiled/Mega2560-optiboot/uploadOTA.bat
Normal file
1
compiled/Mega2560-optiboot/uploadOTA.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
..\tools\arduinoOTA.exe -address 192.168.11.213 -port 80 -username arduino -password password -sketch firmware.bin -b -upload /sketch
|
||||||
Binary file not shown.
1
compiled/esp8266-wifi/ota.bat
Normal file
1
compiled/esp8266-wifi/ota.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
arduinoOTA -address 192.168.88.54 -port 80 -username arduino -password password -b -upload /sketch -sketch firmware.bin
|
||||||
1
compiled/mega2560slim-5100/update_bin.sh
Normal file
1
compiled/mega2560slim-5100/update_bin.sh
Normal file
@@ -0,0 +1 @@
|
|||||||
|
cp ../../.pio/build/lighthub21/firmware.bin .
|
||||||
BIN
compiled/tools/arduinoOTA
Normal file
BIN
compiled/tools/arduinoOTA
Normal file
Binary file not shown.
BIN
compiled/tools/arduinoOTA.exe
Normal file
BIN
compiled/tools/arduinoOTA.exe
Normal file
Binary file not shown.
BIN
compiled/tools/mac/tool-esptool/avrdude
Normal file
BIN
compiled/tools/mac/tool-esptool/avrdude
Normal file
Binary file not shown.
BIN
compiled/tools/win/tool-esptool/esptool
Normal file
BIN
compiled/tools/win/tool-esptool/esptool
Normal file
Binary file not shown.
16
compiled/update_bin.bat
Normal file
16
compiled/update_bin.bat
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
copy ..\.pio\build\due\firmware.bin due
|
||||||
|
copy ..\.pio\build\controllino\firmware.hex controllino
|
||||||
|
copy ..\.pio\build\m5stack\firmware.bin m5stack
|
||||||
|
copy ..\.pio\build\mega2560slim-5100\firmware.hex mega2560slim-5100
|
||||||
|
copy ..\.pio\build\mega2560slim-5100\firmware.bin mega2560slim-5100
|
||||||
|
copy ..\.pio\build\mega2560slim2\firmware.hex mega2560slim2
|
||||||
|
copy ..\.pio\build\mega2560slim2\firmware.bin mega2560slim2
|
||||||
|
copy ..\.pio\build\due-5100\firmware.bin due-5100
|
||||||
|
copy ..\.pio\build\mega2560-5100\firmware.hex mega2560-5100
|
||||||
|
copy ..\.pio\build\due-5500\firmware.bin due-5500
|
||||||
|
copy ..\.pio\build\nrf52840\firmware.hex nrf52840-5500
|
||||||
|
copy ..\.pio\build\esp32-wifi\firmware.bin esp32-wifi
|
||||||
|
copy ..\.pio\build\stm32-enc2860\firmware.bin stm32-enc2860
|
||||||
|
copy ..\.pio\build\esp8266-wifi\firmware.bin esp8266-wifi
|
||||||
|
copy ..\.pio\build\lighthub21\firmware.bin lighthub21
|
||||||
|
copy ..\.pio\build\mega2560-5500\firmware.hex mega2560-5500
|
||||||
25
config-examples/sonoff_s26_humidity_controller.json
Normal file
25
config-examples/sonoff_s26_humidity_controller.json
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"syslog":["95.31.43.9"],
|
||||||
|
"items": {
|
||||||
|
"ledhum":[6,-13],
|
||||||
|
"reghum": [13, [
|
||||||
|
[50, 10, 0, 60, 250, 200], [{"item": "relayhum"}, {"item":"ledhum"}]
|
||||||
|
], 30, 12],
|
||||||
|
|
||||||
|
"relayhum": [16, [12, 1200], 255, 2]
|
||||||
|
},
|
||||||
|
"in":{
|
||||||
|
"0":{"T":0,
|
||||||
|
"click":{ "item":"reghum","icmd":"TOGGLE"},
|
||||||
|
"dclick":{ "emit":"myhome/light-d2/light","ecmd":"TOGGLE"}
|
||||||
|
},
|
||||||
|
|
||||||
|
"3":{"T":4,
|
||||||
|
"temp":{"emit":"plugtemp"},
|
||||||
|
"hum":{"item":"reghum/val","emit":"plughum"}
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
"mqtt":["plug00","192.168.88.2"]
|
||||||
|
}
|
||||||
BIN
docs/html/mkspiffs_espressif32_arduino.exe
Normal file
BIN
docs/html/mkspiffs_espressif32_arduino.exe
Normal file
Binary file not shown.
BIN
docs/html/mkspiffs_espressif8266_arduino.exe
Normal file
BIN
docs/html/mkspiffs_espressif8266_arduino.exe
Normal file
Binary file not shown.
3
docs/html/search/upload.bat
Normal file
3
docs/html/search/upload.bat
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
mode com3:1200,n,8,1
|
||||||
|
pause
|
||||||
|
..\tools\win\tool-bossac\bossac.exe -i --port=com3 -U false -e -w -v -b firmware.bin -R
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
|
import os
|
||||||
Import("env")
|
Import("env")
|
||||||
script = env.GetProjectOption("_upload_command")
|
|
||||||
|
|
||||||
|
script = env.GetProjectOption("_upload_command")
|
||||||
|
spath = os.path.abspath(script)
|
||||||
#env.Replace(
|
#env.Replace(
|
||||||
# UPLOADER="executable or path to executable",
|
# UPLOADER="executable or path to executable",
|
||||||
# UPLOADCMD=script
|
# UPLOADCMD=script
|
||||||
@@ -8,5 +10,4 @@ script = env.GetProjectOption("_upload_command")
|
|||||||
env.AddCustomTarget(
|
env.AddCustomTarget(
|
||||||
"ota",
|
"ota",
|
||||||
"$BUILD_DIR/${PROGNAME}.bin",
|
"$BUILD_DIR/${PROGNAME}.bin",
|
||||||
script
|
spath)
|
||||||
)
|
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ NRFFlashStorage EEPROM;
|
|||||||
debugSerial<<(F(" Res:"))<<res<<endl;
|
debugSerial<<(F(" Res:"))<<res<<endl;
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
void flashStream::close() {fs.close(); debugSerial<<filename<<" Closed\n";};
|
void flashStream::close() {fs.flush();fs.close(); debugSerial<<filename<<" Closed\n";};
|
||||||
void flashStream::flush() {fs.flush(); debugSerial<<filename<<" Flushed\n";};
|
void flashStream::flush() {fs.flush(); debugSerial<<filename<<" Flushed\n";};
|
||||||
size_t flashStream::write(uint8_t ch)
|
size_t flashStream::write(uint8_t ch)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -464,6 +464,8 @@ void Input::dht22Poll() {
|
|||||||
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||||
DHTesp dhtSensor;
|
DHTesp dhtSensor;
|
||||||
dhtSensor.setup(pin, DHTesp::DHT22);
|
dhtSensor.setup(pin, DHTesp::DHT22);
|
||||||
|
//pinMode(pin, INPUT_PULLUP);
|
||||||
|
//digitalWrite(pin, LOW); // Switch bus to receive data
|
||||||
TempAndHumidity dhtSensorData = dhtSensor.getTempAndHumidity();
|
TempAndHumidity dhtSensorData = dhtSensor.getTempAndHumidity();
|
||||||
float temp = roundf(dhtSensorData.temperature * 10) / 10;
|
float temp = roundf(dhtSensorData.temperature * 10) / 10;
|
||||||
float humidity = roundf(dhtSensorData.humidity);
|
float humidity = roundf(dhtSensorData.humidity);
|
||||||
@@ -479,8 +481,8 @@ debugSerial << F("IN:") << pin << F(" DHT22 type. T=") << temp << F("°C H=") <<
|
|||||||
// New tyle unified activities
|
// New tyle unified activities
|
||||||
aJsonObject *actT = aJson.getObjectItem(inputObj, "temp");
|
aJsonObject *actT = aJson.getObjectItem(inputObj, "temp");
|
||||||
aJsonObject *actH = aJson.getObjectItem(inputObj, "hum");
|
aJsonObject *actH = aJson.getObjectItem(inputObj, "hum");
|
||||||
executeCommand(actT,-1,itemCmd(temp));
|
if (!isnan(temp)) executeCommand(actT,-1,itemCmd(temp));
|
||||||
executeCommand(actH,-1,itemCmd(humidity));
|
if (!isnan(humidity)) executeCommand(actH,-1,itemCmd(humidity));
|
||||||
|
|
||||||
//Legacy action conf - TODO - remove in further releases
|
//Legacy action conf - TODO - remove in further releases
|
||||||
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||||
|
|||||||
@@ -39,13 +39,26 @@ e-mail anklimov@gmail.com
|
|||||||
Syslog udpSyslog(udpSyslogClient, SYSLOG_PROTO_BSD);
|
Syslog udpSyslog(udpSyslogClient, SYSLOG_PROTO_BSD);
|
||||||
static char syslogDeviceHostname[16];
|
static char syslogDeviceHostname[16];
|
||||||
|
|
||||||
Streamlog debugSerial(&debugSerialPort,LOG_DEBUG,&udpSyslog);
|
#if defined(debugSerialPort)
|
||||||
Streamlog errorSerial(&debugSerialPort,LOG_ERROR,&udpSyslog,ledRED);
|
Streamlog debugSerial(&debugSerialPort,LOG_DEBUG,&udpSyslog);
|
||||||
Streamlog infoSerial (&debugSerialPort,LOG_INFO,&udpSyslog);
|
Streamlog errorSerial(&debugSerialPort,LOG_ERROR,&udpSyslog,ledRED);
|
||||||
|
Streamlog infoSerial (&debugSerialPort,LOG_INFO,&udpSyslog);
|
||||||
|
#else
|
||||||
|
Streamlog debugSerial(NULL,LOG_DEBUG,&udpSyslog);
|
||||||
|
Streamlog errorSerial(NULL,LOG_ERROR,&udpSyslog,ledRED);
|
||||||
|
Streamlog infoSerial (NULL,LOG_INFO,&udpSyslog);
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
Streamlog debugSerial(&debugSerialPort,LOG_DEBUG);
|
#if defined(debugSerialPort)
|
||||||
Streamlog errorSerial(&debugSerialPort,LOG_ERROR, ledRED);
|
Streamlog debugSerial(&debugSerialPort,LOG_DEBUG);
|
||||||
Streamlog infoSerial (&debugSerialPort,LOG_INFO);
|
Streamlog errorSerial(&debugSerialPort,LOG_ERROR, ledRED);
|
||||||
|
Streamlog infoSerial (&debugSerialPort,LOG_INFO);
|
||||||
|
#else
|
||||||
|
Streamlog debugSerial(NULL,LOG_DEBUG);
|
||||||
|
Streamlog errorSerial(NULL,LOG_ERROR, ledRED);
|
||||||
|
Streamlog infoSerial (NULL,LOG_INFO);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
flashStream sysConfStream;
|
flashStream sysConfStream;
|
||||||
@@ -400,12 +413,11 @@ if (lanStatus == RETAINING_COLLECTING)
|
|||||||
{
|
{
|
||||||
if (mqttClient.isRetained())
|
if (mqttClient.isRetained())
|
||||||
{
|
{
|
||||||
pfxlen=inTopic(topic,T_BCST);
|
//pfxlen=inTopic(topic,T_BCST); //Dont delete bcast topics (just skip on restore retaining)
|
||||||
if (!pfxlen) pfxlen = inTopic(topic,T_DEV);
|
//if (!pfxlen) pfxlen = inTopic(topic,T_DEV);
|
||||||
if (!pfxlen) return; // Not command topic ever
|
pfxlen = inTopic(topic,T_DEV);
|
||||||
//itemName=topic+pfxlen;
|
if (!pfxlen) return; // Not command topic
|
||||||
if (strrchr(topic,'$')) return;
|
if (strrchr(topic,'$')) return;
|
||||||
//if (itemName[0]=='$') return;// -6; //Skipping homie stuff
|
|
||||||
debugSerial<<F("CleanUp retained topic ")<<topic<<endl;
|
debugSerial<<F("CleanUp retained topic ")<<topic<<endl;
|
||||||
mqttClient.deleteTopic(topic);
|
mqttClient.deleteTopic(topic);
|
||||||
}
|
}
|
||||||
@@ -585,6 +597,7 @@ lan_status lanLoop() {
|
|||||||
if (isTimeOver(WiFiAwaitingTime,millis(),WIFI_TIMEOUT))
|
if (isTimeOver(WiFiAwaitingTime,millis(),WIFI_TIMEOUT))
|
||||||
{
|
{
|
||||||
errorSerial<<F("\nProblem with WiFi!");
|
errorSerial<<F("\nProblem with WiFi!");
|
||||||
|
WiFi.reconnect();
|
||||||
return lanStatus = DO_REINIT;
|
return lanStatus = DO_REINIT;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -697,6 +710,19 @@ lan_status lanLoop() {
|
|||||||
if (mqttClient.connected()) mqttClient.disconnect();
|
if (mqttClient.connected()) mqttClient.disconnect();
|
||||||
timerLanCheckTime = millis();// + 5000;
|
timerLanCheckTime = millis();// + 5000;
|
||||||
lanStatus = RECONNECT;
|
lanStatus = RECONNECT;
|
||||||
|
|
||||||
|
/*
|
||||||
|
#if defined(WIFI_ENABLE)
|
||||||
|
if (WiFi.status() != WL_CONNECTED)
|
||||||
|
{
|
||||||
|
infoSerial<<"Reconnecting WiFi"<<endl;
|
||||||
|
lanStatus = INITIAL_STATE;
|
||||||
|
WiFi.disconnect();
|
||||||
|
WiFi.reconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RECONNECT:
|
case RECONNECT:
|
||||||
@@ -1002,7 +1028,7 @@ void ip_ready_config_loaded_connecting_to_broker() {
|
|||||||
|
|
||||||
setTopic(buf,sizeof(buf),T_DEV);
|
setTopic(buf,sizeof(buf),T_DEV);
|
||||||
strncat(buf, "#", sizeof(buf));
|
strncat(buf, "#", sizeof(buf));
|
||||||
debugSerialPort.println(buf);
|
debugSerial.println(buf);
|
||||||
mqttClient.subscribe(buf);
|
mqttClient.subscribe(buf);
|
||||||
|
|
||||||
//onMQTTConnect();
|
//onMQTTConnect();
|
||||||
@@ -1500,27 +1526,6 @@ if (arg_cnt>1)
|
|||||||
#else
|
#else
|
||||||
sysConfStream.open(FN_CONFIG_JSON,'w');
|
sysConfStream.open(FN_CONFIG_JSON,'w');
|
||||||
#endif
|
#endif
|
||||||
/*
|
|
||||||
#if defined(__SAM3X8E__)
|
|
||||||
long configBufSize = min(MAX_JSON_CONF_SIZE,freeRam()-1024);
|
|
||||||
debugSerial<<"Allocate "<<configBufSize<<" bytes for buffer"<<endl;
|
|
||||||
char* outBuf = (char*) malloc(configBufSize);
|
|
||||||
if (!outBuf)
|
|
||||||
{
|
|
||||||
sysConfStream.close();
|
|
||||||
errorSerial<<"Can't allocate RAM"<<endl;
|
|
||||||
return 500;
|
|
||||||
}
|
|
||||||
infoSerial<<F("Saving config to EEPROM..")<<endl;
|
|
||||||
aJsonStringStream stringStream(NULL, outBuf, configBufSize-2);
|
|
||||||
aJson.print(root, &stringStream);
|
|
||||||
int len = strlen(outBuf);
|
|
||||||
outBuf[len++]= EOFchar;
|
|
||||||
infoSerial<<len<< F(" bytes collected")<<endl;
|
|
||||||
size_t res = sysConfStream.write((byte*) outBuf,len);
|
|
||||||
free (outBuf);
|
|
||||||
infoSerial<<res<< F(" bytes are saved to EEPROM")<<endl;
|
|
||||||
#else */
|
|
||||||
|
|
||||||
aJsonStream jsonEEPROMStream = aJsonStream(&sysConfStream);
|
aJsonStream jsonEEPROMStream = aJsonStream(&sysConfStream);
|
||||||
infoSerial<<F("Saving config to EEPROM..");
|
infoSerial<<F("Saving config to EEPROM..");
|
||||||
@@ -1995,13 +2000,113 @@ int16_t attachTimer(double microseconds, timerCallback callback, const char* Tim
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(WIFI_ENABLE)
|
||||||
|
#if defined (ESP32)
|
||||||
|
void WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info)
|
||||||
|
{
|
||||||
|
debugSerial.printf("[WiFi-event] event: %d\n", event);
|
||||||
|
|
||||||
|
switch (event) {
|
||||||
|
case SYSTEM_EVENT_WIFI_READY:
|
||||||
|
debugSerial.println("WiFi interface ready");
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_SCAN_DONE:
|
||||||
|
debugSerial.println("Completed scan for access points");
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_STA_START:
|
||||||
|
debugSerial.println("WiFi client started");
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_STA_STOP:
|
||||||
|
debugSerial.println("WiFi client stopped");
|
||||||
|
//changeState(MYSTATE_OFFLINE);
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_STA_CONNECTED:
|
||||||
|
debugSerial.println("Connected to access point");
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_STA_DISCONNECTED:
|
||||||
|
debugSerial.println("Disconnected from WiFi access point");
|
||||||
|
WiFi.reconnect();
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_STA_AUTHMODE_CHANGE:
|
||||||
|
debugSerial.println("Authentication mode of access point has changed");
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_STA_GOT_IP:
|
||||||
|
debugSerial.print("Obtained IP address: ");
|
||||||
|
//Serial.println(WiFi.localIP());
|
||||||
|
//Serial.println("WiFi connected");
|
||||||
|
//Serial.print("IP address: ");
|
||||||
|
debugSerial.println(IPAddress(info.got_ip.ip_info.ip.addr));
|
||||||
|
|
||||||
|
//changeState(MYSTATE_ONLINE);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_STA_LOST_IP:
|
||||||
|
debugSerial.println("Lost IP address and IP address is reset to 0");
|
||||||
|
//changeState(MYSTATE_OFFLINE);
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_STA_WPS_ER_SUCCESS:
|
||||||
|
debugSerial.println("WiFi Protected Setup (WPS): succeeded in enrollee mode");
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_STA_WPS_ER_FAILED:
|
||||||
|
debugSerial.println("WiFi Protected Setup (WPS): failed in enrollee mode");
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_STA_WPS_ER_TIMEOUT:
|
||||||
|
debugSerial.println("WiFi Protected Setup (WPS): timeout in enrollee mode");
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_STA_WPS_ER_PIN:
|
||||||
|
debugSerial.println("WiFi Protected Setup (WPS): pin code in enrollee mode");
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_AP_START:
|
||||||
|
debugSerial.println("WiFi access point started");
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_AP_STOP:
|
||||||
|
debugSerial.println("WiFi access point stopped");
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_AP_STACONNECTED:
|
||||||
|
debugSerial.println("Client connected");
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_AP_STADISCONNECTED:
|
||||||
|
debugSerial.println("Client disconnected");
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_AP_STAIPASSIGNED:
|
||||||
|
debugSerial.println("Assigned IP address to client");
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_AP_PROBEREQRECVED:
|
||||||
|
debugSerial.println("Received probe request");
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_GOT_IP6:
|
||||||
|
debugSerial.println("IPv6 is preferred");
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_ETH_START:
|
||||||
|
debugSerial.println("Ethernet started");
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_ETH_STOP:
|
||||||
|
debugSerial.println("Ethernet stopped");
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_ETH_CONNECTED:
|
||||||
|
debugSerial.println("Ethernet connected");
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_ETH_DISCONNECTED:
|
||||||
|
debugSerial.println("Ethernet disconnected");
|
||||||
|
break;
|
||||||
|
case SYSTEM_EVENT_ETH_GOT_IP:
|
||||||
|
debugSerial.println("Obtained IP address");
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
void setup_main() {
|
void setup_main() {
|
||||||
|
|
||||||
#if (SERIAL_BAUD)
|
#if (SERIAL_BAUD)
|
||||||
debugSerialPort.begin(SERIAL_BAUD);
|
#if defined(debugSerialPort)
|
||||||
|
debugSerialPort.begin(SERIAL_BAUD);
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#if not defined (__SAM3X8E__)
|
#if not defined (__SAM3X8E__) && defined (debugSerialPort)
|
||||||
debugSerialPort.begin();
|
debugSerialPort.begin();
|
||||||
#endif
|
#endif
|
||||||
delay(1000);
|
delay(1000);
|
||||||
@@ -2020,11 +2125,15 @@ void setup_main() {
|
|||||||
if(SPIFFS.begin())
|
if(SPIFFS.begin())
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
#if defined(debugSerialPort)
|
||||||
debugSerialPort.println("SPIFFS Initialize....ok");
|
debugSerialPort.println("SPIFFS Initialize....ok");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if defined(debugSerialPort)
|
||||||
debugSerialPort.println("SPIFFS Initialization...failed");
|
debugSerialPort.println("SPIFFS Initialization...failed");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
@@ -2039,7 +2148,9 @@ void setup_main() {
|
|||||||
|
|
||||||
if (!sysConf.isValidSysConf())
|
if (!sysConf.isValidSysConf())
|
||||||
{
|
{
|
||||||
|
#if defined(debugSerialPort)
|
||||||
debugSerialPort.println(F("No valid EEPROM data. Initializing."));
|
debugSerialPort.println(F("No valid EEPROM data. Initializing."));
|
||||||
|
#endif
|
||||||
sysConf.clear();
|
sysConf.clear();
|
||||||
}
|
}
|
||||||
// scan_i2c_bus();
|
// scan_i2c_bus();
|
||||||
@@ -2092,6 +2203,11 @@ void setup_main() {
|
|||||||
//#ifdef _artnet
|
//#ifdef _artnet
|
||||||
// artnetSetup();
|
// artnetSetup();
|
||||||
//#endif
|
//#endif
|
||||||
|
#if defined(WIFI_ENABLE)
|
||||||
|
#if defined (ESP32)
|
||||||
|
WiFi.onEvent(WiFiEvent);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(WIFI_ENABLE) and not defined(WIFI_MANAGER_DISABLE)
|
#if defined(WIFI_ENABLE) and not defined(WIFI_MANAGER_DISABLE)
|
||||||
// WiFiManager wifiManager;
|
// WiFiManager wifiManager;
|
||||||
|
|||||||
@@ -21,16 +21,21 @@ static bool CCS811ready = false;
|
|||||||
|
|
||||||
int in_ccs811::Setup()
|
int in_ccs811::Setup()
|
||||||
{
|
{
|
||||||
if (CCS811ready) {debugSerial<<F("ccs811 is already initialized")<<endl; return 0;}
|
if (CCS811ready) {errorSerial<<F("ccs811 is already initialized")<<endl; return 0;}
|
||||||
|
|
||||||
#ifdef WAK_PIN
|
#ifdef WAK_PIN
|
||||||
pinMode(WAK_PIN,OUTPUT);
|
pinMode(WAK_PIN,OUTPUT);
|
||||||
digitalWrite(WAK_PIN,LOW);
|
digitalWrite(WAK_PIN,LOW);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
debugSerial.println("CCS811 Init");
|
infoSerial.println("CCS811 Init");
|
||||||
|
|
||||||
|
#if defined (TWI_SCL) && defined (TWI_SDA)
|
||||||
|
Wire.begin(TWI_SDA,TWI_SCL); //Inialize I2C Harware
|
||||||
|
#else
|
||||||
Wire.begin(); //Inialize I2C Harware
|
Wire.begin(); //Inialize I2C Harware
|
||||||
|
#endif
|
||||||
|
|
||||||
Wire.setClock(4000);
|
Wire.setClock(4000);
|
||||||
|
|
||||||
//It is recommended to check return status on .begin(), but it is not
|
//It is recommended to check return status on .begin(), but it is not
|
||||||
@@ -40,7 +45,7 @@ Wire.setClock(4000);
|
|||||||
if (returnCode != CCS811Core::SENSOR_SUCCESS)
|
if (returnCode != CCS811Core::SENSOR_SUCCESS)
|
||||||
//if (returnCode != CCS811Core::CCS811_Stat_SUCCESS)
|
//if (returnCode != CCS811Core::CCS811_Stat_SUCCESS)
|
||||||
{
|
{
|
||||||
Serial.print("CCS811 Init error ");
|
errorSerial.print("CCS811 Init error ");
|
||||||
//debugSerial.println(ccs811.statusString(returnCode));
|
//debugSerial.println(ccs811.statusString(returnCode));
|
||||||
printDriverError(returnCode);
|
printDriverError(returnCode);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -116,8 +121,8 @@ if (reg!=0xff)
|
|||||||
// New tyle unified activities
|
// New tyle unified activities
|
||||||
aJsonObject *actT = aJson.getObjectItem(in->inputObj, "temp");
|
aJsonObject *actT = aJson.getObjectItem(in->inputObj, "temp");
|
||||||
aJsonObject *actH = aJson.getObjectItem(in->inputObj, "hum");
|
aJsonObject *actH = aJson.getObjectItem(in->inputObj, "hum");
|
||||||
executeCommand(actT,-1,itemCmd(t));
|
if (!isnan(t)) executeCommand(actT,-1,itemCmd(t));
|
||||||
executeCommand(actH,-1,itemCmd(h));
|
if (!isnan(t)) executeCommand(actH,-1,itemCmd(h));
|
||||||
|
|
||||||
publish(t,"/T");
|
publish(t,"/T");
|
||||||
publish(h,"/H");
|
publish(h,"/H");
|
||||||
|
|||||||
@@ -11,14 +11,21 @@
|
|||||||
#define CCS811_ADDR 0x5A //Alternate I2C Address
|
#define CCS811_ADDR 0x5A //Alternate I2C Address
|
||||||
|
|
||||||
#if defined (ARDUINO_ARCH_ESP8266)
|
#if defined (ARDUINO_ARCH_ESP8266)
|
||||||
#define twi_scl D1
|
|
||||||
#ifndef WAK_PIN
|
|
||||||
#define WAK_PIN D3
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SCL_LOW() (GPES = (1 << twi_scl))
|
#if not defined (TWI_SCL) && defined (D1)
|
||||||
#define SCL_HIGH() (GPEC = (1 << twi_scl))
|
#define TWI_SCL D1
|
||||||
#define SCL_RESET
|
#endif
|
||||||
|
|
||||||
|
#if not defined (WAK_PIN) && defined (D3)
|
||||||
|
#define WAK_PIN D3
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined (TWI_SCL)
|
||||||
|
#define SCL_LOW() (GPES = (1 << TWI_SCL))
|
||||||
|
#define SCL_HIGH() (GPEC = (1 << TWI_SCL))
|
||||||
|
#define SCL_RESET
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ while (i)
|
|||||||
case CMD_OFF:
|
case CMD_OFF:
|
||||||
cmd.Percents255(0);
|
cmd.Percents255(0);
|
||||||
}
|
}
|
||||||
if (cmdObj->valueint == CMD_ON && setObj->valueint<20)
|
if (isNotRetainingStatus() && (cmdObj->valueint == CMD_ON) && (setObj->valueint<20))
|
||||||
{
|
{
|
||||||
setObj->valueint=30;
|
setObj->valueint=30;
|
||||||
cmd.Percents255(30);
|
cmd.Percents255(30);
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ if (store && store->pid && (Status() == CST_INITIALIZED) && item && (item->getCm
|
|||||||
if (((abs(store->output-store->prevOut)>OUTPUT_TRESHOLD) || (item->getCmd() == CMD_ENABLE)) && !store->alarmArmed)
|
if (((abs(store->output-store->prevOut)>OUTPUT_TRESHOLD) || (item->getCmd() == CMD_ENABLE)) && !store->alarmArmed)
|
||||||
{
|
{
|
||||||
aJsonObject * oCmd = aJson.getArrayItem(item->itemArg, 1);
|
aJsonObject * oCmd = aJson.getArrayItem(item->itemArg, 1);
|
||||||
if (item->getCmd() == CMD_ENABLE)
|
if ((item->getCmd() == CMD_ENABLE) && (store->output>0.))
|
||||||
{
|
{
|
||||||
executeCommand(oCmd,-1,itemCmd().Cmd(CMD_ON));
|
executeCommand(oCmd,-1,itemCmd().Cmd(CMD_ON));
|
||||||
item->setCmd(CMD_VOID);
|
item->setCmd(CMD_VOID);
|
||||||
@@ -350,6 +350,7 @@ case S_CMD:
|
|||||||
item->setCmd(CMD_ENABLE);
|
item->setCmd(CMD_ENABLE);
|
||||||
item->SendStatus(SEND_COMMAND);
|
item->SendStatus(SEND_COMMAND);
|
||||||
executeCommand(oCmd,-1,value);
|
executeCommand(oCmd,-1,value);
|
||||||
|
store->prevOut=-2.0;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case CMD_DISABLE:
|
case CMD_DISABLE:
|
||||||
|
|||||||
@@ -303,12 +303,14 @@
|
|||||||
//#ifdef M5STACK
|
//#ifdef M5STACK
|
||||||
//#define debugSerial M5.Lcd
|
//#define debugSerial M5.Lcd
|
||||||
//#endif
|
//#endif
|
||||||
|
#ifdef noSerial
|
||||||
#ifndef debugSerialPort
|
#undef debugSerialPort
|
||||||
#define debugSerialPort Serial
|
#else
|
||||||
|
#ifndef debugSerialPort
|
||||||
|
#define debugSerialPort Serial
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef Wiz5500
|
#ifndef Wiz5500
|
||||||
#define W5100_ETHERNET_SHIELD
|
#define W5100_ETHERNET_SHIELD
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -516,11 +516,13 @@ lib_deps =
|
|||||||
[env:esp8266-wifi]
|
[env:esp8266-wifi]
|
||||||
platform = espressif8266
|
platform = espressif8266
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = nodemcuv2
|
;board = nodemcuv2
|
||||||
|
board = esp01_1m
|
||||||
extra_scripts = extra_script.py
|
extra_scripts = extra_script.py
|
||||||
|
board_build.ldscript = eagle.flash.1m64.ld
|
||||||
;upload_protocol = esptool
|
;upload_protocol = esptool
|
||||||
build_type = debug
|
;build_type = debug
|
||||||
monitor_filters = esp8266_exception_decoder
|
;monitor_filters = esp8266_exception_decoder
|
||||||
|
|
||||||
;upload_protocol = espota
|
;upload_protocol = espota
|
||||||
;upload_port = Lighthub.local
|
;upload_port = Lighthub.local
|
||||||
@@ -534,7 +536,7 @@ monitor_filters = esp8266_exception_decoder
|
|||||||
;upload_command = arduinoOTA -address 192.168.1.17 -port 80 -username arduino -password password -b -upload /sketch -sketch $SOURCE ;sleep 6
|
;upload_command = arduinoOTA -address 192.168.1.17 -port 80 -username arduino -password password -b -upload /sketch -sketch $SOURCE ;sleep 6
|
||||||
|
|
||||||
;Alternatively, use OTA script for target ota (pio -t ota). Place appropriate script to custom-build-flags/ to allow OTA by one click
|
;Alternatively, use OTA script for target ota (pio -t ota). Place appropriate script to custom-build-flags/ to allow OTA by one click
|
||||||
_upload_command = custom-build-flags/upload_esp8266-wifi $SOURCE
|
_upload_command = custom-build-flags/upload_esp8266-wifi.bat $SOURCE
|
||||||
|
|
||||||
build_flags = !python get_build_flags.py esp8266-wifi
|
build_flags = !python get_build_flags.py esp8266-wifi
|
||||||
|
|
||||||
|
|||||||
455
variant.cpp.original
Normal file
455
variant.cpp.original
Normal file
@@ -0,0 +1,455 @@
|
|||||||
|
//void USART0_Handler(void)=>void USART0_Handler(void ) __attribute__((weak)); void USART0_Handler(void )
|
||||||
|
//void USART0_Handler(void)=>void USART0_Handler(void ) __attribute__((weak)); void USART0_Handler(void )
|
||||||
|
/*
|
||||||
|
Copyright (c) 2011 Arduino. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "variant.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DUE Board pin | PORT | Label
|
||||||
|
* ----------------+--------+-------
|
||||||
|
* 0 | PA8 | "RX0"
|
||||||
|
* 1 | PA9 | "TX0"
|
||||||
|
* 2 TIOA0 | PB25 |
|
||||||
|
* 3 TIOA7 | PC28 |
|
||||||
|
* 4 NPCS1 | PA29 |
|
||||||
|
* TIOB6 | PC26 |
|
||||||
|
* 5 TIOA6 | PC25 |
|
||||||
|
* 6 PWML7 | PC24 |
|
||||||
|
* 7 PWML6 | PC23 |
|
||||||
|
* 8 PWML5 | PC22 |
|
||||||
|
* 9 PWML4 | PC21 |
|
||||||
|
* 10 NPCS0 | PA28 |
|
||||||
|
* TIOB7 | PC29 |
|
||||||
|
* 11 TIOA8 | PD7 |
|
||||||
|
* 12 TIOB8 | PD8 |
|
||||||
|
* 13 TIOB0 | PB27 | LED AMBER "L"
|
||||||
|
* 14 TXD3 | PD4 | "TX3"
|
||||||
|
* 15 RXD3 | PD5 | "RX3"
|
||||||
|
* 16 TXD1 | PA13 | "TX2"
|
||||||
|
* 17 RXD1 | PA12 | "RX2"
|
||||||
|
* 18 TXD0 | PA11 | "TX1"
|
||||||
|
* 19 RXD0 | PA10 | "RX1"
|
||||||
|
* 20 | PB12 | "SDA"
|
||||||
|
* 21 | PB13 | "SCL"
|
||||||
|
* 22 | PB26 |
|
||||||
|
* 23 | PA14 |
|
||||||
|
* 24 | PA15 |
|
||||||
|
* 25 | PD0 |
|
||||||
|
* 26 | PD1 |
|
||||||
|
* 27 | PD2 |
|
||||||
|
* 28 | PD3 |
|
||||||
|
* 29 | PD6 |
|
||||||
|
* 30 | PD9 |
|
||||||
|
* 31 | PA7 |
|
||||||
|
* 32 | PD10 |
|
||||||
|
* 33 | PC1 |
|
||||||
|
* 34 | PC2 |
|
||||||
|
* 35 | PC3 |
|
||||||
|
* 36 | PC4 |
|
||||||
|
* 37 | PC5 |
|
||||||
|
* 38 | PC6 |
|
||||||
|
* 39 | PC7 |
|
||||||
|
* 40 | PC8 |
|
||||||
|
* 41 | PC9 |
|
||||||
|
* 42 | PA19 |
|
||||||
|
* 43 | PA20 |
|
||||||
|
* 44 | PC19 |
|
||||||
|
* 45 | PC18 |
|
||||||
|
* 46 | PC17 |
|
||||||
|
* 47 | PC16 |
|
||||||
|
* 48 | PC15 |
|
||||||
|
* 49 | PC14 |
|
||||||
|
* 50 | PC13 |
|
||||||
|
* 51 | PC12 |
|
||||||
|
* 52 NPCS2 | PB21 |
|
||||||
|
* 53 | PB14 |
|
||||||
|
* 54 | PA16 | "A0"
|
||||||
|
* 55 | PA24 | "A1"
|
||||||
|
* 56 | PA23 | "A2"
|
||||||
|
* 57 | PA22 | "A3"
|
||||||
|
* 58 TIOB2 | PA6 | "A4"
|
||||||
|
* 69 | PA4 | "A5"
|
||||||
|
* 60 TIOB1 | PA3 | "A6"
|
||||||
|
* 61 TIOA1 | PA2 | "A7"
|
||||||
|
* 62 | PB17 | "A8"
|
||||||
|
* 63 | PB18 | "A9"
|
||||||
|
* 64 | PB19 | "A10"
|
||||||
|
* 65 | PB20 | "A11"
|
||||||
|
* 66 | PB15 | "DAC0"
|
||||||
|
* 67 | PB16 | "DAC1"
|
||||||
|
* 68 | PA1 | "CANRX"
|
||||||
|
* 69 | PA0 | "CANTX"
|
||||||
|
* 70 | PA17 | "SDA1"
|
||||||
|
* 71 | PA18 | "SCL1"
|
||||||
|
* 72 | PC30 | LED AMBER "RX"
|
||||||
|
* 73 | PA21 | LED AMBER "TX"
|
||||||
|
* 74 MISO | PA25 |
|
||||||
|
* 75 MOSI | PA26 |
|
||||||
|
* 76 SCLK | PA27 |
|
||||||
|
* 77 NPCS0 | PA28 |
|
||||||
|
* 78 NPCS3 | PB23 | unconnected!
|
||||||
|
*
|
||||||
|
* USB pin | PORT
|
||||||
|
* ----------------+--------
|
||||||
|
* ID | PB11
|
||||||
|
* VBOF | PB10
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pins descriptions
|
||||||
|
*/
|
||||||
|
extern const PinDescription g_APinDescription[]=
|
||||||
|
{
|
||||||
|
// 0 .. 53 - Digital pins
|
||||||
|
// ----------------------
|
||||||
|
// 0/1 - UART (Serial)
|
||||||
|
{ PIOA, PIO_PA8A_URXD, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // URXD
|
||||||
|
{ PIOA, PIO_PA9A_UTXD, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // UTXD
|
||||||
|
|
||||||
|
// 2
|
||||||
|
{ PIOB, PIO_PB25B_TIOA0, ID_PIOB, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC0_CHA0 }, // TIOA0
|
||||||
|
{ PIOC, PIO_PC28B_TIOA7, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHA7 }, // TIOA7
|
||||||
|
{ PIOC, PIO_PC26B_TIOB6, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHB6 }, // TIOB6
|
||||||
|
|
||||||
|
// 5
|
||||||
|
{ PIOC, PIO_PC25B_TIOA6, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHA6 }, // TIOA6
|
||||||
|
{ PIOC, PIO_PC24B_PWML7, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), NO_ADC, NO_ADC, PWM_CH7, NOT_ON_TIMER }, // PWML7
|
||||||
|
{ PIOC, PIO_PC23B_PWML6, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), NO_ADC, NO_ADC, PWM_CH6, NOT_ON_TIMER }, // PWML6
|
||||||
|
{ PIOC, PIO_PC22B_PWML5, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), NO_ADC, NO_ADC, PWM_CH5, NOT_ON_TIMER }, // PWML5
|
||||||
|
{ PIOC, PIO_PC21B_PWML4, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), NO_ADC, NO_ADC, PWM_CH4, NOT_ON_TIMER }, // PWML4
|
||||||
|
// 10
|
||||||
|
{ PIOC, PIO_PC29B_TIOB7, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHB7 }, // TIOB7
|
||||||
|
{ PIOD, PIO_PD7B_TIOA8, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHA8 }, // TIOA8
|
||||||
|
{ PIOD, PIO_PD8B_TIOB8, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHB8 }, // TIOB8
|
||||||
|
|
||||||
|
// 13 - AMBER LED
|
||||||
|
{ PIOB, PIO_PB27B_TIOB0, ID_PIOB, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC0_CHB0 }, // TIOB0
|
||||||
|
|
||||||
|
// 14/15 - USART3 (Serial3)
|
||||||
|
{ PIOD, PIO_PD4B_TXD3, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TXD3
|
||||||
|
{ PIOD, PIO_PD5B_RXD3, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // RXD3
|
||||||
|
|
||||||
|
// 16/17 - USART1 (Serial2)
|
||||||
|
{ PIOA, PIO_PA13A_TXD1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TXD1
|
||||||
|
{ PIOA, PIO_PA12A_RXD1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // RXD1
|
||||||
|
|
||||||
|
// 18/19 - USART0 (Serial1)
|
||||||
|
{ PIOA, PIO_PA11A_TXD0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TXD0
|
||||||
|
{ PIOA, PIO_PA10A_RXD0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // RXD0
|
||||||
|
|
||||||
|
// 20/21 - TWI1
|
||||||
|
{ PIOB, PIO_PB12A_TWD1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TWD1 - SDA0
|
||||||
|
{ PIOB, PIO_PB13A_TWCK1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TWCK1 - SCL0
|
||||||
|
|
||||||
|
// 22
|
||||||
|
{ PIOB, PIO_PB26, ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 22
|
||||||
|
{ PIOA, PIO_PA14, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 23
|
||||||
|
{ PIOA, PIO_PA15, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 24
|
||||||
|
{ PIOD, PIO_PD0, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 25
|
||||||
|
|
||||||
|
// 26
|
||||||
|
{ PIOD, PIO_PD1, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 26
|
||||||
|
{ PIOD, PIO_PD2, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 27
|
||||||
|
{ PIOD, PIO_PD3, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 28
|
||||||
|
{ PIOD, PIO_PD6, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 29
|
||||||
|
|
||||||
|
// 30
|
||||||
|
{ PIOD, PIO_PD9, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 30
|
||||||
|
{ PIOA, PIO_PA7, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 31
|
||||||
|
{ PIOD, PIO_PD10, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 32
|
||||||
|
{ PIOC, PIO_PC1, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 33
|
||||||
|
|
||||||
|
// 34
|
||||||
|
{ PIOC, PIO_PC2, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 34
|
||||||
|
{ PIOC, PIO_PC3, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 35
|
||||||
|
{ PIOC, PIO_PC4, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 36
|
||||||
|
{ PIOC, PIO_PC5, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 37
|
||||||
|
|
||||||
|
// 38
|
||||||
|
{ PIOC, PIO_PC6, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 38
|
||||||
|
{ PIOC, PIO_PC7, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 39
|
||||||
|
{ PIOC, PIO_PC8, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 40
|
||||||
|
{ PIOC, PIO_PC9, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 41
|
||||||
|
|
||||||
|
// 42
|
||||||
|
{ PIOA, PIO_PA19, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 42
|
||||||
|
{ PIOA, PIO_PA20, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 43
|
||||||
|
{ PIOC, PIO_PC19, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 44
|
||||||
|
{ PIOC, PIO_PC18, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 45
|
||||||
|
|
||||||
|
// 46
|
||||||
|
{ PIOC, PIO_PC17, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 46
|
||||||
|
{ PIOC, PIO_PC16, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 47
|
||||||
|
{ PIOC, PIO_PC15, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 48
|
||||||
|
{ PIOC, PIO_PC14, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 49
|
||||||
|
|
||||||
|
// 50
|
||||||
|
{ PIOC, PIO_PC13, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 50
|
||||||
|
{ PIOC, PIO_PC12, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 51
|
||||||
|
{ PIOB, PIO_PB21, ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 52
|
||||||
|
{ PIOB, PIO_PB14, ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 53
|
||||||
|
|
||||||
|
|
||||||
|
// 54 .. 65 - Analog pins
|
||||||
|
// ----------------------
|
||||||
|
{ PIOA, PIO_PA16X1_AD7, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC0, ADC7, NOT_ON_PWM, NOT_ON_TIMER }, // AD0
|
||||||
|
{ PIOA, PIO_PA24X1_AD6, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC1, ADC6, NOT_ON_PWM, NOT_ON_TIMER }, // AD1
|
||||||
|
{ PIOA, PIO_PA23X1_AD5, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC2, ADC5, NOT_ON_PWM, NOT_ON_TIMER }, // AD2
|
||||||
|
{ PIOA, PIO_PA22X1_AD4, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC3, ADC4, NOT_ON_PWM, NOT_ON_TIMER }, // AD3
|
||||||
|
// 58
|
||||||
|
{ PIOA, PIO_PA6X1_AD3, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC4, ADC3, NOT_ON_PWM, TC0_CHB2 }, // AD4
|
||||||
|
{ PIOA, PIO_PA4X1_AD2, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC5, ADC2, NOT_ON_PWM, NOT_ON_TIMER }, // AD5
|
||||||
|
{ PIOA, PIO_PA3X1_AD1, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC6, ADC1, NOT_ON_PWM, TC0_CHB1 }, // AD6
|
||||||
|
{ PIOA, PIO_PA2X1_AD0, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC7, ADC0, NOT_ON_PWM, TC0_CHA1 }, // AD7
|
||||||
|
// 62
|
||||||
|
{ PIOB, PIO_PB17X1_AD10, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC8, ADC10, NOT_ON_PWM, NOT_ON_TIMER }, // AD8
|
||||||
|
{ PIOB, PIO_PB18X1_AD11, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC9, ADC11, NOT_ON_PWM, NOT_ON_TIMER }, // AD9
|
||||||
|
{ PIOB, PIO_PB19X1_AD12, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC10, ADC12, NOT_ON_PWM, NOT_ON_TIMER }, // AD10
|
||||||
|
{ PIOB, PIO_PB20X1_AD13, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC11, ADC13, NOT_ON_PWM, NOT_ON_TIMER }, // AD11
|
||||||
|
|
||||||
|
// 66/67 - DAC0/DAC1
|
||||||
|
{ PIOB, PIO_PB15X1_DAC0, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC12, DA0, NOT_ON_PWM, NOT_ON_TIMER }, // DAC0
|
||||||
|
{ PIOB, PIO_PB16X1_DAC1, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC13, DA1, NOT_ON_PWM, NOT_ON_TIMER }, // DAC1
|
||||||
|
|
||||||
|
// 68/69 - CANRX0/CANTX0
|
||||||
|
{ PIOA, PIO_PA1A_CANRX0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, ADC14, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // CANRX
|
||||||
|
{ PIOA, PIO_PA0A_CANTX0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, ADC15, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // CANTX
|
||||||
|
|
||||||
|
// 70/71 - TWI0
|
||||||
|
{ PIOA, PIO_PA17A_TWD0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TWD0 - SDA1
|
||||||
|
{ PIOA, PIO_PA18A_TWCK0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TWCK0 - SCL1
|
||||||
|
|
||||||
|
// 72/73 - LEDs
|
||||||
|
{ PIOC, PIO_PC30, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // LED AMBER RXL
|
||||||
|
{ PIOA, PIO_PA21, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // LED AMBER TXL
|
||||||
|
|
||||||
|
// 74/75/76 - SPI
|
||||||
|
{ PIOA, PIO_PA25A_SPI0_MISO,ID_PIOA,PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // MISO
|
||||||
|
{ PIOA, PIO_PA26A_SPI0_MOSI,ID_PIOA,PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // MOSI
|
||||||
|
{ PIOA, PIO_PA27A_SPI0_SPCK,ID_PIOA,PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // SPCK
|
||||||
|
|
||||||
|
// 77 - SPI CS0
|
||||||
|
{ PIOA, PIO_PA28A_SPI0_NPCS0,ID_PIOA,PIO_PERIPH_A,PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // NPCS0
|
||||||
|
|
||||||
|
// 78 - SPI CS3 (unconnected)
|
||||||
|
{ PIOB, PIO_PB23B_SPI0_NPCS3,ID_PIOB,PIO_PERIPH_B,PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // NPCS3
|
||||||
|
|
||||||
|
// 79 .. 84 - "All pins" masks
|
||||||
|
|
||||||
|
// 79 - TWI0 all pins
|
||||||
|
{ PIOA, PIO_PA17A_TWD0|PIO_PA18A_TWCK0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
||||||
|
// 80 - TWI1 all pins
|
||||||
|
{ PIOB, PIO_PB12A_TWD1|PIO_PB13A_TWCK1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
||||||
|
// 81 - UART (Serial) all pins
|
||||||
|
{ PIOA, PIO_PA8A_URXD|PIO_PA9A_UTXD, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
||||||
|
// 82 - USART0 (Serial1) all pins
|
||||||
|
{ PIOA, PIO_PA11A_TXD0|PIO_PA10A_RXD0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
||||||
|
// 83 - USART1 (Serial2) all pins
|
||||||
|
{ PIOA, PIO_PA13A_TXD1|PIO_PA12A_RXD1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
||||||
|
// 84 - USART3 (Serial3) all pins
|
||||||
|
{ PIOD, PIO_PD4B_TXD3|PIO_PD5B_RXD3, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
||||||
|
|
||||||
|
// 85 - USB
|
||||||
|
{ PIOB, PIO_PB11A_UOTGID|PIO_PB10A_UOTGVBOF, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // ID - VBOF
|
||||||
|
|
||||||
|
// 86 - SPI CS2
|
||||||
|
{ PIOB, PIO_PB21B_SPI0_NPCS2, ID_PIOB, PIO_PERIPH_B, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // NPCS2
|
||||||
|
|
||||||
|
// 87 - SPI CS1
|
||||||
|
{ PIOA, PIO_PA29A_SPI0_NPCS1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // NPCS1
|
||||||
|
|
||||||
|
// 88/89 - CANRX1/CANTX1 (same physical pin for 66/53)
|
||||||
|
{ PIOB, PIO_PB15A_CANRX1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // CANRX1
|
||||||
|
{ PIOB, PIO_PB14A_CANTX1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // CANTX1
|
||||||
|
|
||||||
|
// 90 .. 91 - "All CAN pins" masks
|
||||||
|
// 90 - CAN0 all pins
|
||||||
|
{ PIOA, PIO_PA1A_CANRX0|PIO_PA0A_CANTX0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
||||||
|
// 91 - CAN1 all pins
|
||||||
|
{ PIOB, PIO_PB15A_CANRX1|PIO_PB14A_CANTX1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
||||||
|
|
||||||
|
// END
|
||||||
|
{ NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, 0, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t g_pinStatus[PINS_COUNT] = {0};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* UART objects
|
||||||
|
*/
|
||||||
|
RingBuffer rx_buffer1;
|
||||||
|
RingBuffer tx_buffer1;
|
||||||
|
|
||||||
|
UARTClass Serial(UART, UART_IRQn, ID_UART, &rx_buffer1, &tx_buffer1);
|
||||||
|
void serialEvent() __attribute__((weak));
|
||||||
|
void serialEvent() { }
|
||||||
|
|
||||||
|
// IT handlers
|
||||||
|
void UART_Handler(void)
|
||||||
|
{
|
||||||
|
Serial.IrqHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
/*
|
||||||
|
* USART objects
|
||||||
|
*/
|
||||||
|
RingBuffer rx_buffer2;
|
||||||
|
RingBuffer rx_buffer3;
|
||||||
|
RingBuffer rx_buffer4;
|
||||||
|
RingBuffer tx_buffer2;
|
||||||
|
RingBuffer tx_buffer3;
|
||||||
|
RingBuffer tx_buffer4;
|
||||||
|
|
||||||
|
USARTClass Serial1(USART0, USART0_IRQn, ID_USART0, &rx_buffer2, &tx_buffer2);
|
||||||
|
void serialEvent1() __attribute__((weak));
|
||||||
|
void serialEvent1() { }
|
||||||
|
USARTClass Serial2(USART1, USART1_IRQn, ID_USART1, &rx_buffer3, &tx_buffer3);
|
||||||
|
void serialEvent2() __attribute__((weak));
|
||||||
|
void serialEvent2() { }
|
||||||
|
USARTClass Serial3(USART3, USART3_IRQn, ID_USART3, &rx_buffer4, &tx_buffer4);
|
||||||
|
void serialEvent3() __attribute__((weak));
|
||||||
|
void serialEvent3() { }
|
||||||
|
|
||||||
|
// IT handlers
|
||||||
|
void USART0_Handler(void)
|
||||||
|
{
|
||||||
|
Serial1.IrqHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
void USART1_Handler(void)
|
||||||
|
{
|
||||||
|
Serial2.IrqHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
void USART3_Handler(void)
|
||||||
|
{
|
||||||
|
Serial3.IrqHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void serialEventRun(void)
|
||||||
|
{
|
||||||
|
if (Serial.available()) serialEvent();
|
||||||
|
if (Serial1.available()) serialEvent1();
|
||||||
|
if (Serial2.available()) serialEvent2();
|
||||||
|
if (Serial3.available()) serialEvent3();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void __libc_init_array(void);
|
||||||
|
|
||||||
|
void init( void )
|
||||||
|
{
|
||||||
|
SystemInit();
|
||||||
|
|
||||||
|
// Set Systick to 1ms interval, common to all SAM3 variants
|
||||||
|
if (SysTick_Config(SystemCoreClock / 1000))
|
||||||
|
{
|
||||||
|
// Capture error
|
||||||
|
while (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize C library
|
||||||
|
__libc_init_array();
|
||||||
|
|
||||||
|
// Disable pull-up on every pin
|
||||||
|
for (unsigned i = 0; i < PINS_COUNT; i++)
|
||||||
|
digitalWrite(i, LOW);
|
||||||
|
|
||||||
|
// Enable parallel access on PIO output data registers
|
||||||
|
PIOA->PIO_OWER = 0xFFFFFFFF;
|
||||||
|
PIOB->PIO_OWER = 0xFFFFFFFF;
|
||||||
|
PIOC->PIO_OWER = 0xFFFFFFFF;
|
||||||
|
PIOD->PIO_OWER = 0xFFFFFFFF;
|
||||||
|
|
||||||
|
// Initialize Serial port U(S)ART pins
|
||||||
|
PIO_Configure(
|
||||||
|
g_APinDescription[PINS_UART].pPort,
|
||||||
|
g_APinDescription[PINS_UART].ulPinType,
|
||||||
|
g_APinDescription[PINS_UART].ulPin,
|
||||||
|
g_APinDescription[PINS_UART].ulPinConfiguration);
|
||||||
|
digitalWrite(0, HIGH); // Enable pullup for RX0
|
||||||
|
PIO_Configure(
|
||||||
|
g_APinDescription[PINS_USART0].pPort,
|
||||||
|
g_APinDescription[PINS_USART0].ulPinType,
|
||||||
|
g_APinDescription[PINS_USART0].ulPin,
|
||||||
|
g_APinDescription[PINS_USART0].ulPinConfiguration);
|
||||||
|
PIO_Configure(
|
||||||
|
g_APinDescription[PINS_USART1].pPort,
|
||||||
|
g_APinDescription[PINS_USART1].ulPinType,
|
||||||
|
g_APinDescription[PINS_USART1].ulPin,
|
||||||
|
g_APinDescription[PINS_USART1].ulPinConfiguration);
|
||||||
|
PIO_Configure(
|
||||||
|
g_APinDescription[PINS_USART3].pPort,
|
||||||
|
g_APinDescription[PINS_USART3].ulPinType,
|
||||||
|
g_APinDescription[PINS_USART3].ulPin,
|
||||||
|
g_APinDescription[PINS_USART3].ulPinConfiguration);
|
||||||
|
|
||||||
|
// Initialize USB pins
|
||||||
|
PIO_Configure(
|
||||||
|
g_APinDescription[PINS_USB].pPort,
|
||||||
|
g_APinDescription[PINS_USB].ulPinType,
|
||||||
|
g_APinDescription[PINS_USB].ulPin,
|
||||||
|
g_APinDescription[PINS_USB].ulPinConfiguration);
|
||||||
|
|
||||||
|
// Initialize CAN pins
|
||||||
|
PIO_Configure(
|
||||||
|
g_APinDescription[PINS_CAN0].pPort,
|
||||||
|
g_APinDescription[PINS_CAN0].ulPinType,
|
||||||
|
g_APinDescription[PINS_CAN0].ulPin,
|
||||||
|
g_APinDescription[PINS_CAN0].ulPinConfiguration);
|
||||||
|
PIO_Configure(
|
||||||
|
g_APinDescription[PINS_CAN1].pPort,
|
||||||
|
g_APinDescription[PINS_CAN1].ulPinType,
|
||||||
|
g_APinDescription[PINS_CAN1].ulPin,
|
||||||
|
g_APinDescription[PINS_CAN1].ulPinConfiguration);
|
||||||
|
|
||||||
|
// Initialize Analog Controller
|
||||||
|
pmc_enable_periph_clk(ID_ADC);
|
||||||
|
adc_init(ADC, SystemCoreClock, ADC_FREQ_MAX, ADC_STARTUP_FAST);
|
||||||
|
adc_configure_timing(ADC, 0, ADC_SETTLING_TIME_3, 1);
|
||||||
|
adc_configure_trigger(ADC, ADC_TRIG_SW, 0); // Disable hardware trigger.
|
||||||
|
adc_disable_interrupt(ADC, 0xFFFFFFFF); // Disable all ADC interrupts.
|
||||||
|
adc_disable_all_channel(ADC);
|
||||||
|
|
||||||
|
// Initialize analogOutput module
|
||||||
|
analogOutputInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
Reference in New Issue
Block a user