mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-15 00:02:49 +03:00
AVRISP: allow configuring active-high/low reset programatically
This commit is contained in:
@ -26,15 +26,6 @@ extern "C" {
|
||||
#define malloc os_malloc
|
||||
#define free os_free
|
||||
|
||||
#ifdef AVRISP_ACTIVE_HIGH_RESET
|
||||
#define AVRISP_RESET_ON HIGH
|
||||
#define AVRISP_RESET_OFF LOW
|
||||
#else
|
||||
#define AVRISP_RESET_ON LOW
|
||||
#define AVRISP_RESET_OFF HIGH
|
||||
#endif
|
||||
|
||||
|
||||
// #define AVRISP_DEBUG(fmt, ...) os_printf("[AVRP] " fmt "\r\n", ##__VA_ARGS__ )
|
||||
#define AVRISP_DEBUG(...)
|
||||
|
||||
@ -47,8 +38,8 @@ extern "C" {
|
||||
|
||||
#define beget16(addr) (*addr * 256 + *(addr+1))
|
||||
|
||||
ESP8266AVRISP::ESP8266AVRISP(uint16_t port, uint8_t reset_pin, uint32_t spi_freq, bool reset_state):
|
||||
_reset_pin(reset_pin), _reset_state(reset_state), _spi_freq(spi_freq),
|
||||
ESP8266AVRISP::ESP8266AVRISP(uint16_t port, uint8_t reset_pin, uint32_t spi_freq, bool reset_state, bool reset_activehigh):
|
||||
_reset_pin(reset_pin), _reset_state(reset_state), _spi_freq(spi_freq), _reset_activehigh(reset_activehigh),
|
||||
_server(WiFiServer(port)), _state(AVRISP_STATE_IDLE)
|
||||
{
|
||||
pinMode(_reset_pin, OUTPUT);
|
||||
@ -68,11 +59,7 @@ void ESP8266AVRISP::setSpiFrequency(uint32_t freq) {
|
||||
|
||||
void ESP8266AVRISP::setReset(bool rst) {
|
||||
_reset_state = rst;
|
||||
if (_reset_state) {
|
||||
digitalWrite(_reset_pin, AVRISP_RESET_ON);
|
||||
} else {
|
||||
digitalWrite(_reset_pin, AVRISP_RESET_OFF);
|
||||
}
|
||||
digitalWrite(_reset_pin, _resetLevel(_reset_state));
|
||||
}
|
||||
|
||||
AVRISPState_t ESP8266AVRISP::update() {
|
||||
@ -230,9 +217,9 @@ void ESP8266AVRISP::start_pmode() {
|
||||
|
||||
// try to sync the bus
|
||||
SPI.transfer(0x00);
|
||||
digitalWrite(_reset_pin, AVRISP_RESET_OFF);
|
||||
digitalWrite(_reset_pin, _resetLevel(false));
|
||||
delayMicroseconds(50);
|
||||
digitalWrite(_reset_pin, AVRISP_RESET_ON);
|
||||
digitalWrite(_reset_pin, _resetLevel(true));
|
||||
delay(30);
|
||||
|
||||
spi_transaction(0xAC, 0x53, 0x00, 0x00);
|
||||
|
Reference in New Issue
Block a user