Skip to content

Commit 0e45214

Browse files
committed
Minor refactoring
Renaming, adding static keyword
1 parent b854e0d commit 0e45214

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

cores/esp8266/core_esp8266_si2c.c

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,20 @@ static volatile uint8_t twi_rxBufferIndex;
8787
static void (*twi_onSlaveTransmit)(void);
8888
static void (*twi_onSlaveReceive)(uint8_t*, int);
8989

90-
void onSclChange(void);
91-
void onSdaChange(void);
90+
static void onSclChange(void);
91+
static void onSdaChange(void);
9292

93-
#define TASK_QUEUE_SIZE 1
94-
#define TASK_QUEUE_PRIO 2
93+
#define EVENTTASK_QUEUE_SIZE 1
94+
#define EVENTTASK_QUEUE_PRIO 2
9595

9696
#define TWI_SIG_RANGE 0x00000100
9797
#define TWI_SIG_RX (TWI_SIG_RANGE + 0x01)
9898
#define TWI_SIG_TX (TWI_SIG_RANGE + 0x02)
9999

100-
static ETSEvent task_queue[TASK_QUEUE_SIZE];
101-
static void task(ETSEvent *e);
100+
static ETSEvent eventTaskQueue[EVENTTASK_QUEUE_SIZE];
101+
static void eventTask(ETSEvent *e);
102102
static ETSTimer timer;
103-
void onTimer(void *timer_arg);
103+
static void onTimer(void *timer_arg);
104104

105105
#define SDA_LOW() (GPES = (1 << twi_sda)) //Enable SDA (becomes output and since GPO is 0 for the pin, it will pull the line low)
106106
#define SDA_HIGH() (GPEC = (1 << twi_sda)) //Disable SDA (becomes input and since it has pullup it will go high)
@@ -141,15 +141,13 @@ void twi_setClockStretchLimit(uint32_t limit){
141141
twi_clockStretchLimit = limit * TWI_CLOCK_STRETCH_MULTIPLIER;
142142
}
143143

144-
void twi_init(unsigned char sda, unsigned char scl){
145-
146-
147-
ets_timer_setfn(&timer, onTimer, NULL);
148-
149-
ets_task(task, TASK_QUEUE_PRIO, task_queue, TASK_QUEUE_SIZE);
150-
151-
ets_post(TASK_QUEUE_PRIO, 9, 42);
152-
144+
void twi_init(unsigned char sda, unsigned char scl)
145+
{
146+
// set timer function
147+
ets_timer_setfn(&timer, onTimer, NULL);
148+
149+
// create event task
150+
ets_task(eventTask, EVENTTASK_QUEUE_PRIO, eventTaskQueue, EVENTTASK_QUEUE_SIZE);
153151

154152
twi_sda = sda;
155153
twi_scl = scl;
@@ -409,7 +407,7 @@ void ICACHE_RAM_ATTR onTimer(void *timer_arg)
409407
digitalWrite(13, LOW);
410408
}
411409

412-
static void task(ETSEvent *e)
410+
static void eventTask(ETSEvent *e)
413411
{
414412
digitalWrite(14, HIGH);
415413

@@ -555,7 +553,7 @@ void ICACHE_RAM_ATTR twi_onTwipEvent(uint8_t status)
555553
// callback to user defined callback
556554
//twi_onSlaveReceive(twi_rxBuffer, twi_rxBufferIndex);
557555
//twi_rxBufferLock = true; // This may be necessary
558-
ets_post(TASK_QUEUE_PRIO, TWI_SIG_RX, twi_rxBufferIndex);
556+
ets_post(EVENTTASK_QUEUE_PRIO, TWI_SIG_RX, twi_rxBufferIndex);
559557

560558
// since we submit rx buffer to "wire" library, we can reset it
561559
twi_rxBufferIndex = 0;

0 commit comments

Comments
 (0)