Commit bc7b9236 authored by Johny Mattsson's avatar Johny Mattsson
Browse files

Code cleanup to sort out warnings.

I2S constants have changed; docs updated.
parent dff32e89
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake) include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(nodemcu) project(nodemcu)
# Useful when tidying up code to catch all the warnings.
#idf_build_set_property(COMPILE_OPTIONS "-Werror" "-Werror=deprecated-declarations" APPEND)
...@@ -73,9 +73,9 @@ void ip6str (char *out, const ip6_addr_t *ip) ...@@ -73,9 +73,9 @@ void ip6str (char *out, const ip6_addr_t *ip)
void ipstr_esp (char *out, const esp_ip_addr_t *ip) void ipstr_esp (char *out, const esp_ip_addr_t *ip)
{ {
if (ip->type == ESP_IPADDR_TYPE_V4) if (ip->type == ESP_IPADDR_TYPE_V4)
ip4str (out, &ip->u_addr.ip4); ip4str_esp (out, &ip->u_addr.ip4);
else if (ip->type == ESP_IPADDR_TYPE_V6) else if (ip->type == ESP_IPADDR_TYPE_V6)
ip6str (out, &ip->u_addr.ip6); ip6str_esp (out, &ip->u_addr.ip6);
} }
void ip6str_esp (char *out, const esp_ip6_addr_t *ip) void ip6str_esp (char *out, const esp_ip6_addr_t *ip)
...@@ -92,7 +92,7 @@ void ipstr (char *out, const ip_addr_t *ip) ...@@ -92,7 +92,7 @@ void ipstr (char *out, const ip_addr_t *ip)
void ipstr_esp(char *out, const esp_ip_addr_t *ip) void ipstr_esp(char *out, const esp_ip_addr_t *ip)
{ {
ip4str_esp(out, ip); ip4str_esp(out, &ip->u_addr.ip4);
} }
#endif #endif
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/queue.h" #include "freertos/queue.h"
#include "esp_intr.h" #include "esp_intr_alloc.h"
#include "soc/dport_reg.h" #include "soc/dport_reg.h"
#include <math.h> #include <math.h>
......
...@@ -8,6 +8,3 @@ idf_component_register( ...@@ -8,6 +8,3 @@ idf_component_register(
REQUIRES "platform" "uzlib" "driver_console" REQUIRES "platform" "uzlib" "driver_console"
PRIV_REQUIRES "base_nodemcu" "embedded_lfs" PRIV_REQUIRES "base_nodemcu" "embedded_lfs"
) )
target_compile_options(${COMPONENT_LIB} PRIVATE
-Wno-error=misleading-indentation
)
...@@ -849,7 +849,8 @@ LUALIB_API int luaL_loadfsfile (lua_State *L, const char *filename) { ...@@ -849,7 +849,8 @@ LUALIB_API int luaL_loadfsfile (lua_State *L, const char *filename) {
lf.f = vfs_open(filename, "r"); /* reopen in binary mode */ lf.f = vfs_open(filename, "r"); /* reopen in binary mode */
if (!lf.f) return errfsfile(L, "reopen", fnameindex); if (!lf.f) return errfsfile(L, "reopen", fnameindex);
/* skip eventual `#!...' */ /* skip eventual `#!...' */
while ((c = vfs_getc(lf.f)) != VFS_EOF && c != LUA_SIGNATURE[0]) ; while ((c = vfs_getc(lf.f)) != VFS_EOF && c != LUA_SIGNATURE[0])
;
lf.extraline = 0; lf.extraline = 0;
} }
vfs_ungetc(c, lf.f); vfs_ungetc(c, lf.f);
......
...@@ -256,6 +256,7 @@ static int stripdebug (lua_State *L, Proto *f, int level) { ...@@ -256,6 +256,7 @@ static int stripdebug (lua_State *L, Proto *f, int level) {
sizepackedlineinfo = strlen(cast(char *, f->packedlineinfo))+1; sizepackedlineinfo = strlen(cast(char *, f->packedlineinfo))+1;
f->packedlineinfo = luaM_freearray(L, f->packedlineinfo, sizepackedlineinfo, unsigned char); f->packedlineinfo = luaM_freearray(L, f->packedlineinfo, sizepackedlineinfo, unsigned char);
len += sizepackedlineinfo; len += sizepackedlineinfo;
// fall-through
case 2: case 2:
len += f->sizelocvars * (sizeof(struct LocVar) + sizeof(dummy->tsv) + sizeof(struct LocVar *)); len += f->sizelocvars * (sizeof(struct LocVar) + sizeof(dummy->tsv) + sizeof(struct LocVar *));
f->locvars = luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar); f->locvars = luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar);
...@@ -515,7 +516,7 @@ static Instruction symbexec (const Proto *pt, int lastpc, int reg) { ...@@ -515,7 +516,7 @@ static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
case OP_FORLOOP: case OP_FORLOOP:
case OP_FORPREP: case OP_FORPREP:
checkreg(pt, a+3); checkreg(pt, a+3);
/* go through */ /* fall-through */
case OP_JMP: { case OP_JMP: {
int dest = pc+1+b; int dest = pc+1+b;
/* not full check and jump is forward and do not skip `lastpc'? */ /* not full check and jump is forward and do not skip `lastpc'? */
......
...@@ -360,6 +360,7 @@ static int llex (LexState *ls, SemInfo *seminfo) { ...@@ -360,6 +360,7 @@ static int llex (LexState *ls, SemInfo *seminfo) {
} }
else if (sep == -1) return '['; else if (sep == -1) return '[';
else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING); else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING);
__builtin_unreachable();
} }
case '=': { case '=': {
next(ls); next(ls);
......
...@@ -621,6 +621,7 @@ const TValue *luaH_get (Table *t, const TValue *key) { ...@@ -621,6 +621,7 @@ const TValue *luaH_get (Table *t, const TValue *key) {
return luaH_getnum(t, k); /* use specialized version */ return luaH_getnum(t, k); /* use specialized version */
/* else go through */ /* else go through */
} }
/* fall-through */
default: { default: {
Node *n = mainposition(t, key); Node *n = mainposition(t, key);
do { /* check whether `key' is somewhere in the chain */ do { /* check whether `key' is somewhere in the chain */
...@@ -646,6 +647,7 @@ const TValue *luaH_get_ro (void *t, const TValue *key) { ...@@ -646,6 +647,7 @@ const TValue *luaH_get_ro (void *t, const TValue *key) {
return luaH_getnum_ro(t, k); /* use specialized version */ return luaH_getnum_ro(t, k); /* use specialized version */
/* else go through */ /* else go through */
} }
/* fall-through */
default: { default: {
return luaO_nilobject; return luaO_nilobject;
} }
......
...@@ -96,6 +96,7 @@ static void print_version (lua_State *L) { ...@@ -96,6 +96,7 @@ static void print_version (lua_State *L) {
} }
#if 0
static int getargs (lua_State *L, char **argv, int n) { static int getargs (lua_State *L, char **argv, int n) {
int narg; int narg;
int i; int i;
...@@ -112,6 +113,7 @@ static int getargs (lua_State *L, char **argv, int n) { ...@@ -112,6 +113,7 @@ static int getargs (lua_State *L, char **argv, int n) {
} }
return narg; return narg;
} }
#endif
static int dofsfile (lua_State *L, const char *name) { static int dofsfile (lua_State *L, const char *name) {
int status = luaL_loadfsfile(L, name) || docall(L, 0, 1); int status = luaL_loadfsfile(L, name) || docall(L, 0, 1);
...@@ -200,14 +202,14 @@ static int collectargs (char **argv, int *pi, int *pv, int *pe) { ...@@ -200,14 +202,14 @@ static int collectargs (char **argv, int *pi, int *pv, int *pe) {
return i; return i;
case 'i': case 'i':
notail(argv[i]); notail(argv[i]);
*pi = 1; /* go through */ *pi = 1; /* fall-through */
case 'v': case 'v':
notail(argv[i]); notail(argv[i]);
*pv = 1; *pv = 1;
break; break;
case 'e': case 'e':
*pe = 1; /* go through */ *pe = 1; /* fall-through */
case 'm': /* go through */ case 'm': /* fall-through */
case 'l': case 'l':
if (argv[i][2] == '\0') { if (argv[i][2] == '\0') {
i++; i++;
...@@ -371,7 +373,7 @@ void donejob(lua_Load *load){ ...@@ -371,7 +373,7 @@ void donejob(lua_Load *load){
} }
static void dojob(lua_Load *load){ static void dojob(lua_Load *load){
size_t l, rs; size_t l;
int status; int status;
char *b = load->line; char *b = load->line;
lua_State *L = load->L; lua_State *L = load->L;
......
...@@ -49,8 +49,8 @@ static int check_err (lua_State *L, esp_err_t err) ...@@ -49,8 +49,8 @@ static int check_err (lua_State *L, esp_err_t err)
{ {
switch (err) switch (err)
{ {
case ESP_ERR_INVALID_ARG: luaL_error (L, "invalid argument"); case ESP_ERR_INVALID_ARG: return luaL_error (L, "invalid argument");
case ESP_ERR_INVALID_STATE: luaL_error (L, "internal logic error"); case ESP_ERR_INVALID_STATE: return luaL_error (L, "internal logic error");
case ESP_OK: break; case ESP_OK: break;
} }
return 0; return 0;
......
...@@ -151,7 +151,7 @@ static int node_i2s_start( lua_State *L ) ...@@ -151,7 +151,7 @@ static int node_i2s_start( lua_State *L )
i2s_config.bits_per_sample = is->i2s_bits_per_sample; i2s_config.bits_per_sample = is->i2s_bits_per_sample;
// //
i2s_config.channel_format = opt_checkint(L, "channel", I2S_CHANNEL_FMT_RIGHT_LEFT); i2s_config.channel_format = opt_checkint(L, "channel", I2S_CHANNEL_FMT_RIGHT_LEFT);
i2s_config.communication_format = opt_checkint(L, "format", I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB); i2s_config.communication_format = opt_checkint(L, "format", I2S_COMM_FORMAT_STAND_I2S);
i2s_config.dma_buf_count = opt_checkint_range(L, "buffer_count", 2, 2, 128); i2s_config.dma_buf_count = opt_checkint_range(L, "buffer_count", 2, 2, 128);
i2s_config.dma_buf_len = opt_checkint_range(L, "buffer_len", i2s_config.sample_rate / 100, 8, 1024); i2s_config.dma_buf_len = opt_checkint_range(L, "buffer_len", i2s_config.sample_rate / 100, 8, 1024);
i2s_config.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1; i2s_config.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1;
...@@ -316,12 +316,10 @@ LROT_BEGIN(i2s) ...@@ -316,12 +316,10 @@ LROT_BEGIN(i2s)
LROT_FUNCENTRY( write, node_i2s_write ) LROT_FUNCENTRY( write, node_i2s_write )
LROT_FUNCENTRY( mute, node_i2s_mute ) LROT_FUNCENTRY( mute, node_i2s_mute )
LROT_NUMENTRY( FORMAT_I2S, I2S_COMM_FORMAT_I2S ) LROT_NUMENTRY( FORMAT_I2S_STAND, I2S_COMM_FORMAT_STAND_I2S )
LROT_NUMENTRY( FORMAT_I2S_MSB, I2S_COMM_FORMAT_I2S_MSB ) LROT_NUMENTRY( FORMAT_I2S_MSB, I2S_COMM_FORMAT_STAND_MSB )
LROT_NUMENTRY( FORMAT_I2S_LSB, I2S_COMM_FORMAT_I2S_LSB ) LROT_NUMENTRY( FORMAT_PCM_SHORT, I2S_COMM_FORMAT_STAND_PCM_SHORT )
LROT_NUMENTRY( FORMAT_PCM, I2S_COMM_FORMAT_PCM ) LROT_NUMENTRY( FORMAT_PCM_LONG, I2S_COMM_FORMAT_STAND_PCM_LONG )
LROT_NUMENTRY( FORMAT_PCM_SHORT, I2S_COMM_FORMAT_PCM_SHORT )
LROT_NUMENTRY( FORMAT_PCM_LONG, I2S_COMM_FORMAT_PCM_LONG )
LROT_NUMENTRY( CHANNEL_RIGHT_LEFT, I2S_CHANNEL_FMT_RIGHT_LEFT ) LROT_NUMENTRY( CHANNEL_RIGHT_LEFT, I2S_CHANNEL_FMT_RIGHT_LEFT )
LROT_NUMENTRY( CHANNEL_ALL_LEFT, I2S_CHANNEL_FMT_ALL_LEFT ) LROT_NUMENTRY( CHANNEL_ALL_LEFT, I2S_CHANNEL_FMT_ALL_LEFT )
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include "module.h" #include "module.h"
#include "lauxlib.h" #include "lauxlib.h"
#define U8X8_USE_PINS
#define U8X8_WITH_USER_PTR
#include "u8g2.h" #include "u8g2.h"
#include "u8x8_nodemcu_hal.h" #include "u8x8_nodemcu_hal.h"
......
...@@ -3,15 +3,10 @@ ...@@ -3,15 +3,10 @@
#include "module.h" #include "module.h"
#include "lauxlib.h" #include "lauxlib.h"
#define USE_PIN_LIST
#include "ucg.h" #include "ucg.h"
#include "ucg_nodemcu_hal.h" #include "ucg_nodemcu_hal.h"
#include "ucg_config.h" #include "ucg_config.h"
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
// ESP32 // ESP32
#include "spi_common.h" #include "spi_common.h"
...@@ -25,7 +20,6 @@ ...@@ -25,7 +20,6 @@
#endif #endif
typedef struct typedef struct
{ {
ucg_nodemcu_t ucg; ucg_nodemcu_t ucg;
......
...@@ -161,16 +161,6 @@ void wifi_sta_init (void) ...@@ -161,16 +161,6 @@ void wifi_sta_init (void)
} }
// --- Helper functions -----------------------------------------------------
static void do_connect (esp_event_base_t base, int32_t id, const void *data)
{
(void)base; (void)id; (void)data;
esp_wifi_connect ();
}
// --- Lua API functions ---------------------------------------------------- // --- Lua API functions ----------------------------------------------------
static int wifi_sta_setip(lua_State *L) static int wifi_sta_setip(lua_State *L)
{ {
......
...@@ -206,8 +206,8 @@ static int onewire_rmt_attach_pin( uint8_t gpio_num ) ...@@ -206,8 +206,8 @@ static int onewire_rmt_attach_pin( uint8_t gpio_num )
// attach RMT channels to new gpio pin // attach RMT channels to new gpio pin
// ATTENTION: set pin for rx first since gpio_output_disable() will // ATTENTION: set pin for rx first since gpio_output_disable() will
// remove rmt output signal in matrix! // remove rmt output signal in matrix!
rmt_set_pin( ow_rmt.rx, RMT_MODE_RX, gpio_num ); rmt_set_gpio( ow_rmt.rx, RMT_MODE_RX, gpio_num, false );
rmt_set_pin( ow_rmt.tx, RMT_MODE_TX, gpio_num ); rmt_set_gpio( ow_rmt.tx, RMT_MODE_TX, gpio_num, false );
// force pin direction to input to enable path to RX channel // force pin direction to input to enable path to RX channel
PIN_INPUT_ENABLE(GPIO_PIN_MUX_REG[gpio_num]); PIN_INPUT_ENABLE(GPIO_PIN_MUX_REG[gpio_num]);
......
...@@ -4,6 +4,5 @@ idf_component_register( ...@@ -4,6 +4,5 @@ idf_component_register(
REQUIRES "platform" REQUIRES "platform"
) )
target_compile_options(${COMPONENT_LIB} PRIVATE target_compile_options(${COMPONENT_LIB} PRIVATE
-Wno-error=unused-const-variable
-imacros json_config.h -imacros json_config.h
) )
...@@ -1452,6 +1452,7 @@ static const unsigned short Special_Table[0x80] = { ...@@ -1452,6 +1452,7 @@ static const unsigned short Special_Table[0x80] = {
/* 0x74 */ JSONSL_SPECIALf_TRUE /* <t> */ /* 0x74 */ /* 0x74 */ JSONSL_SPECIALf_TRUE /* <t> */ /* 0x74 */
}; };
#if 0
// Bit tables are order such that the MSB is bit 0. // Bit tables are order such that the MSB is bit 0.
// //
/** /**
...@@ -1486,6 +1487,7 @@ static const char Special_Endings[0x100] = { ...@@ -1486,6 +1487,7 @@ static const char Special_Endings[0x100] = {
/* 0xde */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xfd */ /* 0xde */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xfd */
/* 0xfe */ 0 /* 0xfe */ /* 0xfe */ 0 /* 0xfe */
}; };
#endif
static const uint32_t Special_Endings_bits[0x80 / 32] = { static const uint32_t Special_Endings_bits[0x80 / 32] = {
0b00000000011001000000000000000000, 0b00000000011001000000000000000000,
0b10100000000010000000000000100000, 0b10100000000010000000000000100000,
...@@ -1493,6 +1495,7 @@ static const uint32_t Special_Endings_bits[0x80 / 32] = { ...@@ -1493,6 +1495,7 @@ static const uint32_t Special_Endings_bits[0x80 / 32] = {
0b00000000000000000000000000010100 0b00000000000000000000000000010100
}; };
#if 0
/** /**
* This table contains entries for the allowed whitespace as per RFC 4627 * This table contains entries for the allowed whitespace as per RFC 4627
*/ */
...@@ -1512,8 +1515,10 @@ static const char Allowed_Whitespace[0x100] = { ...@@ -1512,8 +1515,10 @@ static const char Allowed_Whitespace[0x100] = {
/* 0xc1 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xe0 */ /* 0xc1 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xe0 */
/* 0xe1 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* 0xfe */ /* 0xe1 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* 0xfe */
}; };
#endif
static const uint32_t Allowed_Whitespace_bits = 0b00000000011001000000000000000000; static const uint32_t Allowed_Whitespace_bits = 0b00000000011001000000000000000000;
#if 0
static const char String_No_Passthrough[0x100] = { static const char String_No_Passthrough[0x100] = {
/* 0x00 */ 1 /* <NUL> */, /* 0x00 */ /* 0x00 */ 1 /* <NUL> */, /* 0x00 */
/* 0x01 */ 1 /* <SOH> */, /* 0x01 */ /* 0x01 */ 1 /* <SOH> */, /* 0x01 */
...@@ -1577,6 +1582,7 @@ static const char Allowed_Escapes[0x100] = { ...@@ -1577,6 +1582,7 @@ static const char Allowed_Escapes[0x100] = {
/* 0xd6 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xf5 */ /* 0xd6 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xf5 */
/* 0xf6 */ 0,0,0,0,0,0,0,0,0, /* 0xfe */ /* 0xf6 */ 0,0,0,0,0,0,0,0,0, /* 0xfe */
}; };
#endif
static const uint32_t Allowed_Escapes_bits[0x80 / 32] = { static const uint32_t Allowed_Escapes_bits[0x80 / 32] = {
0b00000000000000000000000000000000, 0b00000000000000000000000000000000,
0b00100000000000010000000000000000, 0b00100000000000010000000000000000,
...@@ -1584,6 +1590,7 @@ static const uint32_t Allowed_Escapes_bits[0x80 / 32] = { ...@@ -1584,6 +1590,7 @@ static const uint32_t Allowed_Escapes_bits[0x80 / 32] = {
0b00100010000000100010110000000000 0b00100010000000100010110000000000
}; };
#if 0
/** /**
* This table contains the _values_ for a given (single) escaped character. * This table contains the _values_ for a given (single) escaped character.
*/ */
...@@ -1607,6 +1614,7 @@ static unsigned char Escape_Equivs[0x100] = { ...@@ -1607,6 +1614,7 @@ static unsigned char Escape_Equivs[0x100] = {
/* 0xd5 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xf4 */ /* 0xd5 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xf4 */
/* 0xf5 */ 0,0,0,0,0,0,0,0,0,0 /* 0xfe */ /* 0xf5 */ 0,0,0,0,0,0,0,0,0,0 /* 0xfe */
}; };
#endif
/* Definitions of above-declared static functions */ /* Definitions of above-declared static functions */
static char get_escape_equiv(unsigned c) { static char get_escape_equiv(unsigned c) {
......
...@@ -3,6 +3,8 @@ idf_component_register( ...@@ -3,6 +3,8 @@ idf_component_register(
INCLUDE_DIRS "u8g2/src/clib" INCLUDE_DIRS "u8g2/src/clib"
PRIV_REQUIRES "lua" "platform" PRIV_REQUIRES "lua" "platform"
) )
# 3rd-party source is not warning clean, so suppress for now.
# Revisit when upgrading the ucg submodule.
target_compile_options(${COMPONENT_LIB} PRIVATE target_compile_options(${COMPONENT_LIB} PRIVATE
-Wno-error=unused-const-variable -Wno-unused-const-variable
) )
...@@ -2,6 +2,11 @@ idf_component_register( ...@@ -2,6 +2,11 @@ idf_component_register(
SRC_DIRS "ucg/src/clib" SRC_DIRS "ucg/src/clib"
INCLUDE_DIRS "ucg/src/clib" INCLUDE_DIRS "ucg/src/clib"
) )
# 3rd-party source is not warning clean, so suppress for now.
# Revisit when upgrading the ucg submodule.
target_compile_options(${COMPONENT_LIB} PRIVATE target_compile_options(${COMPONENT_LIB} PRIVATE
-Wno-error=unused-const-variable -Wno-unused-const-variable
-Wno-unused-variable
-Wno-unused-but-set-variable
-Wno-unused-function
) )
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment