ESPMegaPRO-v3-SDK/Template Project/lib/ESPMegaPRO/ESPMegaPRO.h

95 lines
2.3 KiB
C
Raw Normal View History

2023-01-22 16:09:48 +00:00
#ifndef ESPMEGA
#define ESPMEGA
2023-08-26 16:16:51 +00:00
#define ANALOG_CARD_ENABLE
2023-01-22 16:09:48 +00:00
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
#include <PCF8574.h>
2023-08-26 16:16:51 +00:00
#ifdef ANALOG_CARD_ENABLE
#include <Adafruit_ADS1X15.h>
2023-08-27 16:42:08 +00:00
#include <MCP4725.h>
2023-09-09 15:44:08 +00:00
#include <I2C_eeprom.h>
#include <SparkFunDS1307RTC.h>
2023-08-26 16:16:51 +00:00
#endif
2023-01-22 16:09:48 +00:00
2023-08-26 04:31:28 +00:00
#define INPUT_BANK_A_ADDRESS 0x21
2023-08-26 05:47:28 +00:00
#define INPUT_BANK_B_ADDRESS 0x22
#define PWM_BANK_ADDRESS 0x5F
2023-09-09 15:44:08 +00:00
#define RTC_ADDRESS 0x68
2023-08-27 16:42:08 +00:00
#define ANALOG_INPUT_BANK_A_ADDRESS 0x48
#define ANALOG_INPUT_BANK_B_ADDRESS 0x49
#define DAC0_ADDRESS 0x60
#define DAC1_ADDRESS 0x61
#define DAC2_ADDRESS 0x62
#define DAC3_ADDRESS 0x63
2023-09-09 15:44:08 +00:00
#define EEPROM_ADDRESS 0x70
#define ESPMega_RTC rtc
2023-01-22 16:09:48 +00:00
//#define USE_INTERRUPT
2023-08-26 05:47:28 +00:00
#define INPUT_BANK_A_INTERRUPT 36
#define INPUT_BANK_B_INTERRUPT 39
2023-09-09 15:44:08 +00:00
extern I2C_eeprom ESPMega_EEPROM;
2023-01-22 16:09:48 +00:00
/**
* Initiate ESPMega PRO Internal Components
*
* This function will initiate the PWM bank, Input banks, and the EEPROM.
*/
void ESPMega_begin();
/**
* Run ESPMega PRO Internal Routines
*
* This function must be called regularly for the correct
* operation of the ESPMega!
*/
void ESPMega_loop();
/**
* Read one of the ESPMega's Digital Input pins (I0-I15)
*
* @param id The number of the pin to be read
* @return The state of the pin (HIGH/LOW)
*/
bool ESPMega_digitalRead(int id);
/**
* Write a pulse wave modulated signal to one of the ESPMega's
* PWM pins (P0-P15)
*
* @param id The number of the pin to write to
* @param value the "HIGH" duty cycle of the PWM wave (0-4095)
*/
void ESPMega_analogWrite(int id, int value);
/**
* Write a digital signal to one of the ESPMega's
* PWM pins (P0-P15)
*
* @param id The number of the pin to write to
* @param value the new state for the pin (HIGH/LOW)
*/
void ESPMega_digitalWrite(int id, bool value);
void IRAM_ATTR refreshInputBankA();
void IRAM_ATTR refreshInputBankB();
2023-08-26 16:16:51 +00:00
#ifdef ANALOG_CARD_ENABLE
/**
* Read one of the ESPMega Analog Card's Analog Input pins (A0-A7)
*
* @param id The number of the pin to be read
* @return The value of the pin (0-4095)
*/
2023-08-27 16:42:08 +00:00
int16_t ESPMega_analogRead(int id);
/**
* Write a True Analog Signal to one of the ESPMega Analog Card's
* Analog Output pins (AO0-AO3)
*
* @param id The number of the pin to write to
* @param value the analog value of the pin (0-4095)
*/
void ESPMega_dacWrite(int id, int value);
2023-08-26 16:16:51 +00:00
#endif
2023-01-22 16:09:48 +00:00
#endif