Marlin_Firmware/Marlin/src/HAL/HAL_ESP32/HAL.h

131 lines
3.7 KiB
C
Raw Normal View History

2017-10-08 11:38:10 -05:00
/**
* Marlin 3D Printer Firmware
2019-02-12 15:06:53 -06:00
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
2017-10-08 11:38:10 -05:00
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
2017-10-08 11:38:10 -05:00
/**
* Description: HAL for Espressif ESP32 WiFi
*/
#define CPU_32_BIT
// --------------------------------------------------------------------------
// Includes
// --------------------------------------------------------------------------
#include <stdint.h>
2019-05-02 00:45:50 -05:00
#include "../shared/Marduino.h"
#include "../shared/math_32bit.h"
#include "../shared/HAL_SPI.h"
2017-10-08 11:38:10 -05:00
#include "fastio_ESP32.h"
#include "watchdog_ESP32.h"
#include "i2s.h"
2017-10-08 11:38:10 -05:00
#include "HAL_timers_ESP32.h"
2019-03-13 00:48:08 -05:00
#include "WebSocketSerial.h"
#include "FlushableHardwareSerial.h"
2019-03-13 00:48:08 -05:00
2017-10-08 11:38:10 -05:00
// --------------------------------------------------------------------------
// Defines
// --------------------------------------------------------------------------
extern portMUX_TYPE spinlock;
#define MYSERIAL0 flushableSerial
2019-03-13 05:25:54 -05:00
#if ENABLED(WIFISUPPORT)
#define NUM_SERIAL 2
#define MYSERIAL1 webSocketSerial
#else
#define NUM_SERIAL 1
#endif
2017-10-08 11:38:10 -05:00
#define CRITICAL_SECTION_START portENTER_CRITICAL(&spinlock)
#define CRITICAL_SECTION_END portEXIT_CRITICAL(&spinlock)
#define ISRS_ENABLED() (spinlock.owner == portMUX_FREE_VAL)
#define ENABLE_ISRS() if (spinlock.owner != portMUX_FREE_VAL) portEXIT_CRITICAL(&spinlock)
#define DISABLE_ISRS() portENTER_CRITICAL(&spinlock)
// Fix bug in pgm_read_ptr
#undef pgm_read_ptr
#define pgm_read_ptr(addr) (*(addr))
// --------------------------------------------------------------------------
// Types
// --------------------------------------------------------------------------
typedef int16_t pin_t;
2019-05-25 18:12:24 -05:00
#define HAL_SERVO_LIB Servo
2017-10-08 11:38:10 -05:00
// --------------------------------------------------------------------------
// Public Variables
// --------------------------------------------------------------------------
/** result of last ADC conversion */
extern uint16_t HAL_adc_result;
// --------------------------------------------------------------------------
// Public functions
// --------------------------------------------------------------------------
// clear reset reason
void HAL_clear_reset_source (void);
// reset reason
2019-04-12 13:35:30 -05:00
uint8_t HAL_get_reset_source(void);
2017-10-08 11:38:10 -05:00
void _delay_ms(int delay);
int freeMemory(void);
void analogWrite(int pin, int value);
// EEPROM
2018-10-09 18:59:49 -05:00
void eeprom_write_byte(uint8_t *pos, unsigned char value);
uint8_t eeprom_read_byte(uint8_t *pos);
2017-10-08 11:38:10 -05:00
void eeprom_read_block (void *__dst, const void *__src, size_t __n);
void eeprom_update_block (const void *__src, void *__dst, size_t __n);
// ADC
#define HAL_ANALOG_SELECT(pin)
void HAL_adc_init(void);
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
#define HAL_READ_ADC() HAL_adc_result
#define HAL_ADC_READY() true
2017-10-08 11:38:10 -05:00
2019-04-12 13:35:30 -05:00
void HAL_adc_start_conversion(uint8_t adc_pin);
2017-10-08 11:38:10 -05:00
#define GET_PIN_MAP_PIN(index) index
#define GET_PIN_MAP_INDEX(pin) pin
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
// Enable hooks into idle and setup for HAL
#define HAL_IDLETASK 1
#define HAL_INIT 1
2019-05-25 17:06:00 -05:00
#define BOARD_INIT() HAL_init_board();
2017-10-08 11:38:10 -05:00
void HAL_idletask(void);
void HAL_init(void);
2019-05-25 17:06:00 -05:00
void HAL_init_board(void);