Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ With `gu16Tim00Divisor` you can set the granularity of `TG0_Timer0` (I usually s
Finally, `gu64tckSchedulePeriod` determines how often (i.e., when) `prog_cycle_pro()` and `prog_cycle_app()` functions will be called by
the scheduler.


### Features

THis list is supposed to grow longer and longer.
Expand Down
1 change: 1 addition & 0 deletions examples/1rmtdht/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ ESP32.VCC -- S1.+

#### Practices

You can play around with the predefined values, e.g., `RMTDHT_PERIOD_MS`, `RMTDHT_CH` or `RMTINT_CH`.
5 changes: 5 additions & 0 deletions examples/1rmttm1637/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ ESP32.VCC -- X1.VCC

#### Practices

* Write an application that counts down from `10` to `0` (again and again),
and the numbers are smoothly faded in / faded out.

* First, a square should be displayed in the top left corner (`0x63`).
Then, this square should move around the display (clockwise).
6 changes: 0 additions & 6 deletions examples/3prog1/prog.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ typedef struct {
void *pvParam;
} InterruptEntry;

typedef struct {
uint8_t coreId;
uint8_t id;
uint8_t prio;
} InterruptDesc;

typedef enum {
DISPLAY_INIT,
DISPLAY_CLRSCR,
Expand Down
6 changes: 3 additions & 3 deletions modules/tm1637.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static void IRAM_ATTR _clktxend_isr(void *pvParam) {
* @param eChannel CLK RMT channel.
*/
static inline void _init_clkseq(ERmtChannel eChannel) {
RegAddr prClkRam = rmt_ram_addr(eChannel, 1, 1);
RegAddr prClkRam = rmt_ram_addr(eChannel, 1, 1); // cppcheck-suppress unusedVariable
for (int i = 0; i < 9; ++i) {
prClkRam[i] = RMT_ENTRYPAIR(0, CLK_HALFPERIOD_TICKS, 1, CLK_HALFPERIOD_TICKS);
}
Expand All @@ -134,7 +134,7 @@ static inline void _init_clkseq(ERmtChannel eChannel) {
* @param bStart START CLK slice has to be added.
*/
static inline void _update_clkseq(ERmtChannel eChannel, bool bStop, bool bStart) {
RegAddr prClkRam = rmt_ram_addr(eChannel, 1, 0);
RegAddr prClkRam = rmt_ram_addr(eChannel, 1, 0); // cppcheck-suppress unusedVariable
prClkRam[1] = RMT_ENTRYPAIR(0, CLK_HALFPERIOD_TICKS, 1, CLK_HALFPERIOD_TICKS);
if (bStart && !bStop) {
prClkRam[0] = RMT_ENTRYPAIR(1, 1, 1, CLK_HALFPERIOD_TICKS - 1); // 0.5 periods
Expand Down Expand Up @@ -178,7 +178,7 @@ static inline void _dat_dioseq(RegAddr prDioRam, uint8_t u8Dat) {
static inline void _update_dioseq(ERmtChannel eChannel, bool bStop, bool bStart, uint8_t u8Dat) {
static uint32_t u32EntryPairStart = RMT_ENTRYPAIR(0, 1, 0, CLK_HALFPERIOD_TICKS - 1); // 0.5 periods
static uint32_t u32EntryPairStop = RMT_ENTRYPAIR(0, 2 * CLK_HALFPERIOD_TICKS, 1, CLK_HALFPERIOD_TICKS); // 1.5 periods
RegAddr prDioRam = rmt_ram_addr(eChannel, 1, 0);
RegAddr prDioRam = rmt_ram_addr(eChannel, 1, 0); // cppcheck-suppress unusedVariable
if (bStart && !bStop) {
prDioRam[0] = u32EntryPairStart;
_dat_dioseq(prDioRam + 1, u8Dat);
Expand Down
61 changes: 37 additions & 24 deletions src/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,39 @@
// ============== Local types ==============

// ============== Internal function declarations ==============
static inline uint8_t _address(uint8_t u8RawAddr, bool bWrite);
static inline uint8_t _address_read(uint8_t u8RawAddr);
static inline uint8_t _address_write(uint8_t u8RawAddr);
static inline uint8_t _cmd_read_to_regs(Reg *prDest, uint8_t u8RxLen);
static inline uint8_t _scl_idx(EI2CBus eBus);
static inline uint8_t _sda_idx(EI2CBus eBus);
static inline uint8_t _dport_peri_bit(EI2CBus eBus);

// ============== Implementation ==============
// -------------- Internal functions --------------
static inline uint8_t _address(uint8_t u8RawAddr, bool bRead){
return (u8RawAddr << 1) | (bRead ? 1 : 0);
}

static inline uint8_t _address_read(uint8_t u8RawAddr) {
return _address(u8RawAddr, true);
}
static inline uint8_t _address_write(uint8_t u8RawAddr) {
return _address(u8RawAddr, false);
}

static inline uint8_t _cmd_read_to_regs(Reg *prDest, uint8_t u8RxLen) {
uint8_t u8MoreBytes = (1 < u8RxLen ? 1 : 0);
prDest[0] = i2c_cmd_start();
prDest[1] = i2c_cmd_write(true, 1);
if (u8MoreBytes) {
prDest[2] = i2c_cmd_read(false, u8RxLen - 1);
}
prDest[2 + u8MoreBytes] = i2c_cmd_read(true, 1);
prDest[3 + u8MoreBytes] = i2c_cmd_stop();
return 4 + u8MoreBytes;
}

static inline uint8_t _scl_idx(EI2CBus eBus) {
return eBus == I2C0 ? I2C0_SCL_IDX : I2C1_SCL_IDX;
}
Expand All @@ -53,8 +80,8 @@ void i2c_write(EI2CBus eBus, uint8_t u8Addr, uint8_t u8Len, const uint8_t *pu8Da

i2c_reset_fifo(psI2C);

// copy data
prData[0] = (u8Addr << 1) | 0; // slave addr
// put data to be written into the buffer
prData[0] = _address_write(u8Addr); // slave addr
for (int i = 0; i < 31 && i < u8Len; ++i) {
prData[i + 1] = pu8Dat[i];
}
Expand All @@ -71,20 +98,13 @@ void i2c_write(EI2CBus eBus, uint8_t u8Addr, uint8_t u8Len, const uint8_t *pu8Da
void i2c_read(EI2CBus eBus, uint8_t u8Addr, uint8_t u8RxLen) {
I2C_Type *psI2C = i2c_regs(eBus);
RegAddr prData = i2c_nonfifo(eBus);
uint8_t u8MoreBytes = (1 < u8RxLen ? 1 : 0);

i2c_reset_fifo(psI2C);

// WRITE slave addr to buffer
prData[0] = (u8Addr << 1) | 1; // slave addr
// put data to be written into the buffer
prData[0] = _address_read(u8Addr); // slave addr

psI2C->COMD[0] = i2c_cmd_start();
psI2C->COMD[1] = i2c_cmd_write(true, 1);
if (u8MoreBytes) {
psI2C->COMD[2] = i2c_cmd_read(false, u8RxLen - 1);
}
psI2C->COMD[2 + u8MoreBytes] = i2c_cmd_read(true, 1);
psI2C->COMD[3 + u8MoreBytes] = i2c_cmd_stop();
_cmd_read_to_regs(&psI2C->COMD[0], u8RxLen);

// CTR
psI2C->INT_CLR = I2C_INT_MASK_ALL;
Expand All @@ -94,24 +114,17 @@ void i2c_read(EI2CBus eBus, uint8_t u8Addr, uint8_t u8RxLen) {
void i2c_read_mem(EI2CBus eBus, uint8_t u8Addr, uint8_t u8MemAddr, uint8_t u8RxLen) {
I2C_Type *psI2C = i2c_regs(eBus);
RegAddr prData = i2c_nonfifo(eBus);
uint8_t u8MoreBytes = (1 < u8RxLen ? 1 : 0);

i2c_reset_fifo(psI2C);

// WRITE slave addr to buffer
prData[0] = (u8Addr << 1) | 0; // slave addr (WR)
// put data to be written into the buffer
prData[0] = _address_write(u8Addr); // slave addr (WR)
prData[1] = u8MemAddr;
prData[2] = (u8Addr << 1) | 1; // slave addr (RD)
prData[2] = _address_read(u8Addr); // slave addr (RD)

psI2C->COMD[0] = i2c_cmd_start();
psI2C->COMD[1] = i2c_cmd_write(true, 2);
psI2C->COMD[2] = i2c_cmd_start();
psI2C->COMD[3] = i2c_cmd_write(true, 1);
if (u8MoreBytes) {
psI2C->COMD[4] = i2c_cmd_read(false, u8RxLen - 1);
}
psI2C->COMD[4 + u8MoreBytes] = i2c_cmd_read(true, 1);
psI2C->COMD[5 + u8MoreBytes] = i2c_cmd_stop();
psI2C->COMD[1] = i2c_cmd_write(true, 2); // prData[0..1]
_cmd_read_to_regs(&psI2C->COMD[2], u8RxLen);

// CTR
psI2C->INT_CLR = I2C_INT_MASK_ALL;
Expand Down
4 changes: 0 additions & 4 deletions src/print.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ extern "C" {

// ============== Inline interface functions ==============

static inline char *str_append(char *dst, const char *src) {
return strcpy(dst, src) + strlen(src);
}

static inline char *print_dec_padded(char *dst, uint32_t u32Value, uint8_t u8Width, char cPad) {
for (int i = 0; i < u8Width; ++i) {
dst[u8Width - 1 - i] = u32Value ? ZERO_CHR + u32Value % 10U : cPad;
Expand Down
1 change: 1 addition & 0 deletions src/utils/rmtutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ static bool _stretchgen_end(const void *pvState);
* 0; otherwise these bits contain the second value received from the underlying generator.
*/
static uint32_t _pairgen_next(U16Generator pfGen, UniRel pfEnd, void *pvParam) {
// cppcheck-suppress unusedVariable
uint16_t au16Val[] = {0, 0};
uint32_t *pu32Val = (uint32_t*) au16Val;

Expand Down