Skip to content

Commit 8e94809

Browse files
committed
Rename sd->sigmadelta in HAL
Change is to not be mistaken with SD Card
1 parent 5977877 commit 8e94809

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
## Development Status
1717
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:
1818
- 16 channels [LEDC](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-ledc.h) which is PWM
19-
- 8 channels [SigmaDelta](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-sd.h) which uses SigmaDelta modulation
19+
- 8 channels [SigmaDelta](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-sigmadelta.h) which uses SigmaDelta modulation
2020
- 2 channels [DAC](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-dac.h) which gives real analog output
2121

2222
## Installation Instructions

cores/esp32/esp32-hal-sd.c cores/esp32/esp32-hal-sigmadelta.c

+15-15
Original file line numberDiff line numberDiff line change
@@ -31,53 +31,53 @@
3131
xSemaphoreHandle _sd_sys_lock;
3232
#endif
3333

34-
uint32_t sdSetup(uint8_t channel, uint32_t freq) //chan 0-7 freq 1220-312500
34+
uint32_t sigmaDeltaSetup(uint8_t channel, uint32_t freq) //chan 0-7 freq 1220-312500
3535
{
3636
if(channel > 7) {
3737
return 0;
3838
}
39+
#if !CONFIG_DISABLE_HAL_LOCKS
3940
static bool tHasStarted = false;
4041
if(!tHasStarted) {
4142
tHasStarted = true;
42-
#if !CONFIG_DISABLE_HAL_LOCKS
4343
_sd_sys_lock = xSemaphoreCreateMutex();
44-
#endif
4544
}
46-
gpio_sd_dev_t * gpio_sd_dev = (volatile gpio_sd_dev_t *)(DR_REG_GPIO_SD_BASE);
45+
#endif
4746
uint32_t prescale = (10000000/(freq*32)) - 1;
4847
if(prescale > 0xFF) {
4948
prescale = 0xFF;
5049
}
5150
SD_MUTEX_LOCK();
52-
gpio_sd_dev->channel[channel].prescale = prescale;
53-
gpio_sd_dev->cg.clk_en = 0;
54-
gpio_sd_dev->cg.clk_en = 1;
51+
SIGMADELTA.channel[channel].prescale = prescale;
52+
SIGMADELTA.cg.clk_en = 0;
53+
SIGMADELTA.cg.clk_en = 1;
5554
SD_MUTEX_UNLOCK();
5655
return 10000000/((prescale + 1) * 32);
5756
}
5857

59-
void sdWrite(uint8_t channel, uint8_t duty) //chan 0-7 duty 8 bit
58+
void sigmaDeltaWrite(uint8_t channel, uint8_t duty) //chan 0-7 duty 8 bit
6059
{
6160
if(channel > 7) {
6261
return;
6362
}
6463
duty += 128;
65-
gpio_sd_dev_t * gpio_sd_dev = (volatile gpio_sd_dev_t *)(DR_REG_GPIO_SD_BASE);
6664
SD_MUTEX_LOCK();
67-
gpio_sd_dev->channel[channel].duty = duty;
65+
SIGMADELTA.channel[channel].duty = duty;
6866
SD_MUTEX_UNLOCK();
6967
}
7068

71-
uint8_t sdRead(uint8_t channel) //chan 0-7
69+
uint8_t sigmaDeltaRead(uint8_t channel) //chan 0-7
7270
{
7371
if(channel > 7) {
7472
return 0;
7573
}
76-
gpio_sd_dev_t * gpio_sd_dev = (volatile gpio_sd_dev_t *)(DR_REG_GPIO_SD_BASE);
77-
return gpio_sd_dev->channel[channel].duty - 128;
74+
SD_MUTEX_LOCK();
75+
uint8_t duty = SIGMADELTA.channel[channel].duty - 128;
76+
SD_MUTEX_UNLOCK();
77+
return duty;
7878
}
7979

80-
void sdAttachPin(uint8_t pin, uint8_t channel) //channel 0-7
80+
void sigmaDeltaAttachPin(uint8_t pin, uint8_t channel) //channel 0-7
8181
{
8282
if(channel > 7) {
8383
return;
@@ -86,7 +86,7 @@ void sdAttachPin(uint8_t pin, uint8_t channel) //channel 0-7
8686
pinMatrixOutAttach(pin, GPIO_SD0_OUT_IDX + channel, false, false);
8787
}
8888

89-
void sdDetachPin(uint8_t pin)
89+
void sigmaDeltaDetachPin(uint8_t pin)
9090
{
9191
pinMatrixOutDetach(pin, false, false);
9292
}
File renamed without changes.

cores/esp32/esp32-hal.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void vPortYield( void );
5656
#include "esp32-hal-spi.h"
5757
#include "esp32-hal-i2c.h"
5858
#include "esp32-hal-ledc.h"
59-
#include "esp32-hal-sd.h"
59+
#include "esp32-hal-sigmadelta.h"
6060
#include "esp32-hal-timer.h"
6161
#include "esp_system.h"
6262

0 commit comments

Comments
 (0)