Rename sd->sigmadelta in HAL

Change is to not be mistaken with SD Card
This commit is contained in:
me-no-dev 2017-01-09 17:57:17 +02:00
parent 5977877dbe
commit 8e948096d4
4 changed files with 17 additions and 17 deletions

View File

@ -16,7 +16,7 @@
## Development Status ## Development Status
Most of the framework is implemented. Most noticable is the missing analogWrite. While analogWrite is on it's way, there are a few other options that you can use: Most of the framework is implemented. Most noticable is the missing analogWrite. While analogWrite is on it's way, there are a few other options that you can use:
- 16 channels [LEDC](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-ledc.h) which is PWM - 16 channels [LEDC](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-ledc.h) which is PWM
- 8 channels [SigmaDelta](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-sd.h) which uses SigmaDelta modulation - 8 channels [SigmaDelta](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-sigmadelta.h) which uses SigmaDelta modulation
- 2 channels [DAC](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-dac.h) which gives real analog output - 2 channels [DAC](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-dac.h) which gives real analog output
## Installation Instructions ## Installation Instructions

View File

@ -31,53 +31,53 @@
xSemaphoreHandle _sd_sys_lock; xSemaphoreHandle _sd_sys_lock;
#endif #endif
uint32_t sdSetup(uint8_t channel, uint32_t freq) //chan 0-7 freq 1220-312500 uint32_t sigmaDeltaSetup(uint8_t channel, uint32_t freq) //chan 0-7 freq 1220-312500
{ {
if(channel > 7) { if(channel > 7) {
return 0; return 0;
} }
#if !CONFIG_DISABLE_HAL_LOCKS
static bool tHasStarted = false; static bool tHasStarted = false;
if(!tHasStarted) { if(!tHasStarted) {
tHasStarted = true; tHasStarted = true;
#if !CONFIG_DISABLE_HAL_LOCKS
_sd_sys_lock = xSemaphoreCreateMutex(); _sd_sys_lock = xSemaphoreCreateMutex();
#endif
} }
gpio_sd_dev_t * gpio_sd_dev = (volatile gpio_sd_dev_t *)(DR_REG_GPIO_SD_BASE); #endif
uint32_t prescale = (10000000/(freq*32)) - 1; uint32_t prescale = (10000000/(freq*32)) - 1;
if(prescale > 0xFF) { if(prescale > 0xFF) {
prescale = 0xFF; prescale = 0xFF;
} }
SD_MUTEX_LOCK(); SD_MUTEX_LOCK();
gpio_sd_dev->channel[channel].prescale = prescale; SIGMADELTA.channel[channel].prescale = prescale;
gpio_sd_dev->cg.clk_en = 0; SIGMADELTA.cg.clk_en = 0;
gpio_sd_dev->cg.clk_en = 1; SIGMADELTA.cg.clk_en = 1;
SD_MUTEX_UNLOCK(); SD_MUTEX_UNLOCK();
return 10000000/((prescale + 1) * 32); return 10000000/((prescale + 1) * 32);
} }
void sdWrite(uint8_t channel, uint8_t duty) //chan 0-7 duty 8 bit void sigmaDeltaWrite(uint8_t channel, uint8_t duty) //chan 0-7 duty 8 bit
{ {
if(channel > 7) { if(channel > 7) {
return; return;
} }
duty += 128; duty += 128;
gpio_sd_dev_t * gpio_sd_dev = (volatile gpio_sd_dev_t *)(DR_REG_GPIO_SD_BASE);
SD_MUTEX_LOCK(); SD_MUTEX_LOCK();
gpio_sd_dev->channel[channel].duty = duty; SIGMADELTA.channel[channel].duty = duty;
SD_MUTEX_UNLOCK(); SD_MUTEX_UNLOCK();
} }
uint8_t sdRead(uint8_t channel) //chan 0-7 uint8_t sigmaDeltaRead(uint8_t channel) //chan 0-7
{ {
if(channel > 7) { if(channel > 7) {
return 0; return 0;
} }
gpio_sd_dev_t * gpio_sd_dev = (volatile gpio_sd_dev_t *)(DR_REG_GPIO_SD_BASE); SD_MUTEX_LOCK();
return gpio_sd_dev->channel[channel].duty - 128; uint8_t duty = SIGMADELTA.channel[channel].duty - 128;
SD_MUTEX_UNLOCK();
return duty;
} }
void sdAttachPin(uint8_t pin, uint8_t channel) //channel 0-7 void sigmaDeltaAttachPin(uint8_t pin, uint8_t channel) //channel 0-7
{ {
if(channel > 7) { if(channel > 7) {
return; return;
@ -86,7 +86,7 @@ void sdAttachPin(uint8_t pin, uint8_t channel) //channel 0-7
pinMatrixOutAttach(pin, GPIO_SD0_OUT_IDX + channel, false, false); pinMatrixOutAttach(pin, GPIO_SD0_OUT_IDX + channel, false, false);
} }
void sdDetachPin(uint8_t pin) void sigmaDeltaDetachPin(uint8_t pin)
{ {
pinMatrixOutDetach(pin, false, false); pinMatrixOutDetach(pin, false, false);
} }

View File

@ -56,7 +56,7 @@ void vPortYield( void );
#include "esp32-hal-spi.h" #include "esp32-hal-spi.h"
#include "esp32-hal-i2c.h" #include "esp32-hal-i2c.h"
#include "esp32-hal-ledc.h" #include "esp32-hal-ledc.h"
#include "esp32-hal-sd.h" #include "esp32-hal-sigmadelta.h"
#include "esp32-hal-timer.h" #include "esp32-hal-timer.h"
#include "esp_system.h" #include "esp_system.h"