Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
c8037568
Commit
c8037568
authored
Dec 28, 2015
by
Terry Ellison
Browse files
Merge pull request #883 from nodemcu/dev
Resync master to dev prior to upgrading Dev to SDK 1.5
parents
93421f27
a8359f1d
Changes
62
Show whitespace changes
Inline
Side-by-side
app/modules/rtcmem.c
View file @
c8037568
// Module for RTC user memory access
// Module for RTC user memory access
#include "module.h"
#include "lauxlib.h"
#include "lauxlib.h"
#include "rtc/rtcaccess.h"
#include "rtc/rtcaccess.h"
...
@@ -40,21 +41,10 @@ static int rtcmem_write32 (lua_State *L)
...
@@ -40,21 +41,10 @@ static int rtcmem_write32 (lua_State *L)
// Module function map
// Module function map
#define MIN_OPT_LEVEL 2
static
const
LUA_REG_TYPE
rtcmem_map
[]
=
{
#include "lrodefs.h"
const
LUA_REG_TYPE
rtcmem_map
[]
=
{
{
LSTRKEY
(
"read32"
),
LFUNCVAL
(
rtcmem_read32
)
},
{
LSTRKEY
(
"read32"
),
LFUNCVAL
(
rtcmem_read32
)
},
{
LSTRKEY
(
"write32"
),
LFUNCVAL
(
rtcmem_write32
)
},
{
LSTRKEY
(
"write32"
),
LFUNCVAL
(
rtcmem_write32
)
},
{
LNILKEY
,
LNILVAL
}
{
LNILKEY
,
LNILVAL
}
};
};
LUALIB_API
int
luaopen_rtcmem
(
lua_State
*
L
)
NODEMCU_MODULE
(
RTCMEM
,
"rtcmem"
,
rtcmem_map
,
NULL
);
{
#if LUA_OPTIMIZE_MEMORY > 0
return
0
;
#else
luaL_register
(
L
,
AUXLIB_RTCMEM
,
rtcmem_map
);
return
1
;
#endif
}
app/modules/rtctime.c
View file @
c8037568
// Module for RTC time keeping
// Module for RTC time keeping
#include "module.h"
#include "lauxlib.h"
#include "lauxlib.h"
#include "rtc/rtctime_internal.h"
#include "rtc/rtctime_internal.h"
...
@@ -115,10 +116,7 @@ static int rtctime_dsleep_aligned (lua_State *L)
...
@@ -115,10 +116,7 @@ static int rtctime_dsleep_aligned (lua_State *L)
// Module function map
// Module function map
#define MIN_OPT_LEVEL 2
static
const
LUA_REG_TYPE
rtctime_map
[]
=
{
#include "lrodefs.h"
const
LUA_REG_TYPE
rtctime_map
[]
=
{
{
LSTRKEY
(
"set"
),
LFUNCVAL
(
rtctime_set
)
},
{
LSTRKEY
(
"set"
),
LFUNCVAL
(
rtctime_set
)
},
{
LSTRKEY
(
"get"
),
LFUNCVAL
(
rtctime_get
)
},
{
LSTRKEY
(
"get"
),
LFUNCVAL
(
rtctime_get
)
},
{
LSTRKEY
(
"dsleep"
),
LFUNCVAL
(
rtctime_dsleep
)
},
{
LSTRKEY
(
"dsleep"
),
LFUNCVAL
(
rtctime_dsleep
)
},
...
@@ -126,12 +124,4 @@ const LUA_REG_TYPE rtctime_map[] =
...
@@ -126,12 +124,4 @@ const LUA_REG_TYPE rtctime_map[] =
{
LNILKEY
,
LNILVAL
}
{
LNILKEY
,
LNILVAL
}
};
};
LUALIB_API
int
luaopen_rtctime
(
lua_State
*
L
)
NODEMCU_MODULE
(
RTCTIME
,
"rtctime"
,
rtctime_map
,
NULL
);
{
#if LUA_OPTIMIZE_MEMORY > 0
return
0
;
#else
luaL_register
(
L
,
AUXLIB_RTCTIME
,
rtctime_map
);
return
1
;
#endif
}
app/modules/sntp.c
View file @
c8037568
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
// Module for Simple Network Time Protocol (SNTP)
// Module for Simple Network Time Protocol (SNTP)
#include "module.h"
#include "lauxlib.h"
#include "lauxlib.h"
#include "os_type.h"
#include "os_type.h"
#include "osapi.h"
#include "osapi.h"
...
@@ -375,20 +376,9 @@ error:
...
@@ -375,20 +376,9 @@ error:
// Module function map
// Module function map
#define MIN_OPT_LEVEL 2
static
const
LUA_REG_TYPE
sntp_map
[]
=
{
#include "lrodefs.h"
const
LUA_REG_TYPE
sntp_map
[]
=
{
{
LSTRKEY
(
"sync"
),
LFUNCVAL
(
sntp_sync
)
},
{
LSTRKEY
(
"sync"
),
LFUNCVAL
(
sntp_sync
)
},
{
LNILKEY
,
LNILVAL
}
{
LNILKEY
,
LNILVAL
}
};
};
LUALIB_API
int
luaopen_sntp
(
lua_State
*
L
)
NODEMCU_MODULE
(
SNTP
,
"sntp"
,
sntp_map
,
NULL
);
{
#if LUA_OPTIMIZE_MEMORY > 0
return
0
;
#else
luaL_register
(
L
,
AUXLIB_SNTP
,
sntp_map
);
return
1
;
#endif
}
app/modules/spi.c
View file @
c8037568
// Module for interfacing with the SPI interface
// Module for interfacing with the SPI interface
//#include "lua.h"
#include "module.h"
#include "lualib.h"
#include "lauxlib.h"
#include "lauxlib.h"
#include "platform.h"
#include "platform.h"
#include "auxmods.h"
#include "lrotable.h"
#define SPI_HALFDUPLEX 0
#define SPI_HALFDUPLEX 0
#define SPI_FULLDUPLEX 1
#define SPI_FULLDUPLEX 1
...
@@ -33,6 +30,10 @@ static int spi_setup( lua_State *L )
...
@@ -33,6 +30,10 @@ static int spi_setup( lua_State *L )
if
(
cpol
!=
PLATFORM_SPI_CPOL_LOW
&&
cpol
!=
PLATFORM_SPI_CPOL_HIGH
)
{
if
(
cpol
!=
PLATFORM_SPI_CPOL_LOW
&&
cpol
!=
PLATFORM_SPI_CPOL_HIGH
)
{
return
luaL_error
(
L
,
"wrong arg type"
);
return
luaL_error
(
L
,
"wrong arg type"
);
}
}
// CPOL_HIGH is not implemented, see app/driver/spi.c spi_master_init()
if
(
cpol
==
PLATFORM_SPI_CPOL_HIGH
)
{
return
luaL_error
(
L
,
"cpol=high is not implemented"
);
}
if
(
cpha
!=
PLATFORM_SPI_CPHA_LOW
&&
cpha
!=
PLATFORM_SPI_CPHA_HIGH
)
{
if
(
cpha
!=
PLATFORM_SPI_CPHA_LOW
&&
cpha
!=
PLATFORM_SPI_CPHA_HIGH
)
{
return
luaL_error
(
L
,
"wrong arg type"
);
return
luaL_error
(
L
,
"wrong arg type"
);
...
@@ -309,17 +310,13 @@ static int spi_transaction( lua_State *L )
...
@@ -309,17 +310,13 @@ static int spi_transaction( lua_State *L )
// Module function map
// Module function map
#define MIN_OPT_LEVEL 2
static
const
LUA_REG_TYPE
spi_map
[]
=
{
#include "lrodefs.h"
const
LUA_REG_TYPE
spi_map
[]
=
{
{
LSTRKEY
(
"setup"
),
LFUNCVAL
(
spi_setup
)
},
{
LSTRKEY
(
"setup"
),
LFUNCVAL
(
spi_setup
)
},
{
LSTRKEY
(
"send"
),
LFUNCVAL
(
spi_send_recv
)
},
{
LSTRKEY
(
"send"
),
LFUNCVAL
(
spi_send_recv
)
},
{
LSTRKEY
(
"recv"
),
LFUNCVAL
(
spi_recv
)
},
{
LSTRKEY
(
"recv"
),
LFUNCVAL
(
spi_recv
)
},
{
LSTRKEY
(
"set_mosi"
),
LFUNCVAL
(
spi_set_mosi
)
},
{
LSTRKEY
(
"set_mosi"
),
LFUNCVAL
(
spi_set_mosi
)
},
{
LSTRKEY
(
"get_miso"
),
LFUNCVAL
(
spi_get_miso
)
},
{
LSTRKEY
(
"get_miso"
),
LFUNCVAL
(
spi_get_miso
)
},
{
LSTRKEY
(
"transaction"
),
LFUNCVAL
(
spi_transaction
)
},
{
LSTRKEY
(
"transaction"
),
LFUNCVAL
(
spi_transaction
)
},
#if LUA_OPTIMIZE_MEMORY > 0
{
LSTRKEY
(
"MASTER"
),
LNUMVAL
(
PLATFORM_SPI_MASTER
)
},
{
LSTRKEY
(
"MASTER"
),
LNUMVAL
(
PLATFORM_SPI_MASTER
)
},
{
LSTRKEY
(
"SLAVE"
),
LNUMVAL
(
PLATFORM_SPI_SLAVE
)
},
{
LSTRKEY
(
"SLAVE"
),
LNUMVAL
(
PLATFORM_SPI_SLAVE
)
},
{
LSTRKEY
(
"CPHA_LOW"
),
LNUMVAL
(
PLATFORM_SPI_CPHA_LOW
)
},
{
LSTRKEY
(
"CPHA_LOW"
),
LNUMVAL
(
PLATFORM_SPI_CPHA_LOW
)
},
...
@@ -329,28 +326,7 @@ const LUA_REG_TYPE spi_map[] =
...
@@ -329,28 +326,7 @@ const LUA_REG_TYPE spi_map[] =
{
LSTRKEY
(
"DATABITS_8"
),
LNUMVAL
(
8
)
},
{
LSTRKEY
(
"DATABITS_8"
),
LNUMVAL
(
8
)
},
{
LSTRKEY
(
"HALFDUPLEX"
),
LNUMVAL
(
SPI_HALFDUPLEX
)
},
{
LSTRKEY
(
"HALFDUPLEX"
),
LNUMVAL
(
SPI_HALFDUPLEX
)
},
{
LSTRKEY
(
"FULLDUPLEX"
),
LNUMVAL
(
SPI_FULLDUPLEX
)
},
{
LSTRKEY
(
"FULLDUPLEX"
),
LNUMVAL
(
SPI_FULLDUPLEX
)
},
#endif // #if LUA_OPTIMIZE_MEMORY > 0
{
LNILKEY
,
LNILVAL
}
{
LNILKEY
,
LNILVAL
}
};
};
LUALIB_API
int
luaopen_spi
(
lua_State
*
L
)
NODEMCU_MODULE
(
SPI
,
"spi"
,
spi_map
,
NULL
);
{
#if LUA_OPTIMIZE_MEMORY > 0
return
0
;
#else // #if LUA_OPTIMIZE_MEMORY > 0
luaL_register
(
L
,
AUXLIB_SPI
,
spi_map
);
// Add constants
MOD_REG_NUMBER
(
L
,
"MASTER"
,
PLATFORM_SPI_MASTER
);
MOD_REG_NUMBER
(
L
,
"SLAVE"
,
PLATFORM_SPI_SLAVE
);
MOD_REG_NUMBER
(
L
,
"CPHA_LOW"
,
PLATFORM_SPI_CPHA_LOW
);
MOD_REG_NUMBER
(
L
,
"CPHA_HIGH"
,
PLATFORM_SPI_CPHA_HIGH
);
MOD_REG_NUMBER
(
L
,
"CPOL_LOW"
,
PLATFORM_SPI_CPOL_LOW
);
MOD_REG_NUMBER
(
L
,
"CPOL_HIGH"
,
PLATFORM_SPI_CPOL_HIGH
);
MOD_REG_NUMBER
(
L
,
"DATABITS_8"
,
8
);
MOD_REG_NUMBER
(
L
,
"HALFDUPLEX"
,
SPI_HALFDUPLEX
);
MOD_REG_NUMBER
(
L
,
"FULLDUPLEX"
,
SPI_FULLDUPLEX
);
return
1
;
#endif // #if LUA_OPTIMIZE_MEMORY > 0
}
app/modules/tmr.c
View file @
c8037568
...
@@ -48,14 +48,9 @@ tmr.softwd(int)
...
@@ -48,14 +48,9 @@ tmr.softwd(int)
the timer units are seconds
the timer units are seconds
*/
*/
#define MIN_OPT_LEVEL 2
#include "module.h"
#include "lualib.h"
#include "lauxlib.h"
#include "lauxlib.h"
#include "platform.h"
#include "platform.h"
#include "auxmods.h"
#include "lrotable.h"
#include "lrodefs.h"
#include "c_types.h"
#include "c_types.h"
#define TIMER_MODE_OFF 3
#define TIMER_MODE_OFF 3
...
@@ -311,28 +306,26 @@ static int tmr_softwd( lua_State* L ){
...
@@ -311,28 +306,26 @@ static int tmr_softwd( lua_State* L ){
// Module function map
// Module function map
const
LUA_REG_TYPE
tmr_map
[]
=
{
static
const
LUA_REG_TYPE
tmr_map
[]
=
{
{
LSTRKEY
(
"delay"
),
LFUNCVAL
(
tmr_delay
)
},
{
LSTRKEY
(
"delay"
),
LFUNCVAL
(
tmr_delay
)
},
{
LSTRKEY
(
"now"
),
LFUNCVAL
(
tmr_now
)
},
{
LSTRKEY
(
"now"
),
LFUNCVAL
(
tmr_now
)
},
{
LSTRKEY
(
"wdclr"
),
LFUNCVAL
(
tmr_wdclr
)
},
{
LSTRKEY
(
"wdclr"
),
LFUNCVAL
(
tmr_wdclr
)
},
{
LSTRKEY
(
"softwd"
),
LFUNCVAL
(
tmr_softwd
)
},
{
LSTRKEY
(
"softwd"
),
LFUNCVAL
(
tmr_softwd
)
},
{
LSTRKEY
(
"time"
),
LFUNCVAL
(
tmr_time
)
},
{
LSTRKEY
(
"time"
),
LFUNCVAL
(
tmr_time
)
},
{
LSTRKEY
(
"register"
),
LFUNCVAL
(
tmr_register
)
},
{
LSTRKEY
(
"register"
),
LFUNCVAL
(
tmr_register
)
},
{
LSTRKEY
(
"alarm"
),
LFUNCVAL
(
tmr_alarm
)
},
{
LSTRKEY
(
"alarm"
),
LFUNCVAL
(
tmr_alarm
)
},
{
LSTRKEY
(
"start"
),
LFUNCVAL
(
tmr_start
)
},
{
LSTRKEY
(
"start"
),
LFUNCVAL
(
tmr_start
)
},
{
LSTRKEY
(
"stop"
),
LFUNCVAL
(
tmr_stop
)
},
{
LSTRKEY
(
"stop"
),
LFUNCVAL
(
tmr_stop
)
},
{
LSTRKEY
(
"unregister"
),
LFUNCVAL
(
tmr_unregister
)
},
{
LSTRKEY
(
"unregister"
),
LFUNCVAL
(
tmr_unregister
)
},
{
LSTRKEY
(
"state"
),
LFUNCVAL
(
tmr_state
)
},
{
LSTRKEY
(
"state"
),
LFUNCVAL
(
tmr_state
)
},
{
LSTRKEY
(
"interval"
),
LFUNCVAL
(
tmr_interval
)
},
{
LSTRKEY
(
"interval"
),
LFUNCVAL
(
tmr_interval
)
},
#if LUA_OPTIMIZE_MEMORY > 0
{
LSTRKEY
(
"ALARM_SINGLE"
),
LNUMVAL
(
TIMER_MODE_SINGLE
)
},
{
LSTRKEY
(
"ALARM_SINGLE"
),
LNUMVAL
(
TIMER_MODE_SINGLE
)
},
{
LSTRKEY
(
"ALARM_SEMI"
),
LNUMVAL
(
TIMER_MODE_SEMI
)
},
{
LSTRKEY
(
"ALARM_SEMI"
),
LNUMVAL
(
TIMER_MODE_SEMI
)
},
{
LSTRKEY
(
"ALARM_AUTO"
),
LNUMVAL
(
TIMER_MODE_AUTO
)
},
{
LSTRKEY
(
"ALARM_AUTO"
),
LNUMVAL
(
TIMER_MODE_AUTO
)
},
#endif
{
LNILKEY
,
LNILVAL
}
{
LNILKEY
,
LNILVAL
}
};
};
LUALIB_API
int
luaopen_tmr
(
lua_State
*
L
){
int
luaopen_tmr
(
lua_State
*
L
){
int
i
;
int
i
;
for
(
i
=
0
;
i
<
NUM_TMR
;
i
++
){
for
(
i
=
0
;
i
<
NUM_TMR
;
i
++
){
alarm_timers
[
i
].
lua_ref
=
LUA_NOREF
;
alarm_timers
[
i
].
lua_ref
=
LUA_NOREF
;
...
@@ -343,17 +336,7 @@ LUALIB_API int luaopen_tmr( lua_State *L ){
...
@@ -343,17 +336,7 @@ LUALIB_API int luaopen_tmr( lua_State *L ){
ets_timer_disarm
(
&
rtc_timer
);
ets_timer_disarm
(
&
rtc_timer
);
ets_timer_setfn
(
&
rtc_timer
,
rtc_callback
,
NULL
);
ets_timer_setfn
(
&
rtc_timer
,
rtc_callback
,
NULL
);
ets_timer_arm_new
(
&
rtc_timer
,
1000
,
1
,
1
);
ets_timer_arm_new
(
&
rtc_timer
,
1000
,
1
,
1
);
#if LUA_OPTIMIZE_MEMORY > 0
return
0
;
return
0
;
#else
luaL_register
(
L
,
AUXLIB_TMR
,
tmr_map
);
lua_pushvalue
(
L
,
-
1
);
lua_setmetatable
(
L
,
-
2
);
MOD_REG_NUMBER
(
L
,
"ALARM_SINGLE"
,
TIMER_MODE_SINGLE
);
MOD_REG_NUMBER
(
L
,
"ALARM_SEMI"
,
TIMER_MODE_SEMI
);
MOD_REG_NUMBER
(
L
,
"ALARM_AUTO"
,
TIMER_MODE_AUTO
);
return
1
;
#endif
}
}
NODEMCU_MODULE
(
TMR
,
"tmr"
,
tmr_map
,
luaopen_tmr
);
app/modules/tsl2561.c
View file @
c8037568
...
@@ -4,11 +4,9 @@
...
@@ -4,11 +4,9 @@
* Created on: Aug 21, 2015
* Created on: Aug 21, 2015
* Author: Michael Lucas (Aeprox @github)
* Author: Michael Lucas (Aeprox @github)
*/
*/
#include "
lualib
.h"
#include "
module
.h"
#include "lauxlib.h"
#include "lauxlib.h"
#include "platform.h"
#include "platform.h"
#include "auxmods.h"
#include "lrotable.h"
#include "../tsl2561/tsl2561.h"
#include "../tsl2561/tsl2561.h"
static
uint16_t
ch0
;
static
uint16_t
ch0
;
...
@@ -102,38 +100,28 @@ static int ICACHE_FLASH_ATTR tsl2561_lua_getchannels(lua_State* L) {
...
@@ -102,38 +100,28 @@ static int ICACHE_FLASH_ATTR tsl2561_lua_getchannels(lua_State* L) {
return
3
;
return
3
;
}
}
#define MIN_OPT_LEVEL 2
// Module function map
#include "lrodefs.h"
static
const
LUA_REG_TYPE
tsl2561_map
[]
=
{
const
LUA_REG_TYPE
tsl2561_map
[]
=
{
{
LSTRKEY
(
"settiming"
),
LFUNCVAL
(
tsl2561_lua_settiming
)},
{
LSTRKEY
(
"settiming"
),
LFUNCVAL
(
tsl2561_lua_settiming
)},
{
LSTRKEY
(
"getlux"
),
LFUNCVAL
(
tsl2561_lua_calclux
)},
{
LSTRKEY
(
"getlux"
),
LFUNCVAL
(
tsl2561_lua_calclux
)},
{
LSTRKEY
(
"getrawchannels"
),
LFUNCVAL
(
tsl2561_lua_getchannels
)},
{
LSTRKEY
(
"getrawchannels"
),
LFUNCVAL
(
tsl2561_lua_getchannels
)},
{
LSTRKEY
(
"init"
),
LFUNCVAL
(
tsl2561_init
)},
{
LSTRKEY
(
"init"
),
LFUNCVAL
(
tsl2561_init
)},
{
LSTRKEY
(
"TSL2561_OK"
),
LNUMVAL
(
TSL2561_ERROR_OK
)},
{
LSTRKEY
(
"TSL2561_OK"
),
LNUMVAL
(
TSL2561_ERROR_OK
)},
{
LSTRKEY
(
"TSL2561_ERROR_I2CINIT"
),
LNUMVAL
(
TSL2561_ERROR_I2CINIT
)},
{
LSTRKEY
(
"TSL2561_ERROR_I2CINIT"
),
LNUMVAL
(
TSL2561_ERROR_I2CINIT
)},
{
LSTRKEY
(
"TSL2561_ERROR_I2CBUSY"
),
LNUMVAL
(
TSL2561_ERROR_I2CBUSY
)},
{
LSTRKEY
(
"TSL2561_ERROR_I2CBUSY"
),
LNUMVAL
(
TSL2561_ERROR_I2CBUSY
)},
{
LSTRKEY
(
"TSL2561_ERROR_NOINIT"
),
LNUMVAL
(
TSL2561_ERROR_NOINIT
)},
{
LSTRKEY
(
"TSL2561_ERROR_NOINIT"
),
LNUMVAL
(
TSL2561_ERROR_NOINIT
)},
{
LSTRKEY
(
"TSL2561_ERROR_LAST"
),
LNUMVAL
(
TSL2561_ERROR_LAST
)},
{
LSTRKEY
(
"TSL2561_ERROR_LAST"
),
LNUMVAL
(
TSL2561_ERROR_LAST
)},
{
LSTRKEY
(
"INTEGRATIONTIME_13MS"
),
LNUMVAL
(
TSL2561_INTEGRATIONTIME_13MS
)},
{
LSTRKEY
(
"INTEGRATIONTIME_13MS"
),
LNUMVAL
(
TSL2561_INTEGRATIONTIME_13MS
)},
{
LSTRKEY
(
"INTEGRATIONTIME_101MS"
),
LNUMVAL
(
TSL2561_INTEGRATIONTIME_101MS
)},
{
LSTRKEY
(
"INTEGRATIONTIME_101MS"
),
LNUMVAL
(
TSL2561_INTEGRATIONTIME_101MS
)},
{
LSTRKEY
(
"INTEGRATIONTIME_402MS"
),
LNUMVAL
(
TSL2561_INTEGRATIONTIME_402MS
)},
{
LSTRKEY
(
"INTEGRATIONTIME_402MS"
),
LNUMVAL
(
TSL2561_INTEGRATIONTIME_402MS
)},
{
LSTRKEY
(
"GAIN_1X"
),
LNUMVAL
(
TSL2561_GAIN_1X
)},
{
LSTRKEY
(
"GAIN_1X"
),
LNUMVAL
(
TSL2561_GAIN_1X
)},
{
LSTRKEY
(
"GAIN_16X"
),
LNUMVAL
(
TSL2561_GAIN_16X
)},
{
LSTRKEY
(
"GAIN_16X"
),
LNUMVAL
(
TSL2561_GAIN_16X
)},
{
LSTRKEY
(
"PACKAGE_CS"
),
LNUMVAL
(
TSL2561_PACKAGE_CS
)},
{
LSTRKEY
(
"PACKAGE_CS"
),
LNUMVAL
(
TSL2561_PACKAGE_CS
)},
{
LSTRKEY
(
"PACKAGE_T_FN_CL"
),
LNUMVAL
(
TSL2561_PACKAGE_T_FN_CL
)},
{
LSTRKEY
(
"PACKAGE_T_FN_CL"
),
LNUMVAL
(
TSL2561_PACKAGE_T_FN_CL
)},
{
LSTRKEY
(
"ADDRESS_GND"
),
LNUMVAL
(
TSL2561_ADDRESS_GND
)},
{
LSTRKEY
(
"ADDRESS_GND"
),
LNUMVAL
(
TSL2561_ADDRESS_GND
)},
{
LSTRKEY
(
"ADDRESS_FLOAT"
),
LNUMVAL
(
TSL2561_ADDRESS_FLOAT
)},
{
LSTRKEY
(
"ADDRESS_FLOAT"
),
LNUMVAL
(
TSL2561_ADDRESS_FLOAT
)},
{
LSTRKEY
(
"ADDRESS_VDD"
),
LNUMVAL
(
TSL2561_ADDRESS_VDD
)},
{
LSTRKEY
(
"ADDRESS_VDD"
),
LNUMVAL
(
TSL2561_ADDRESS_VDD
)},
{
LNILKEY
,
LNILVAL
}
{
LNILKEY
,
LNILVAL
}
};
};
LUALIB_API
int
luaopen_tsl2561
(
lua_State
*
L
)
{
NODEMCU_MODULE
(
TSL2561
,
"tsl2561"
,
tsl2561_map
,
NULL
);
LREGISTER
(
L
,
"tsl2561"
,
tsl2561_map
);
return
1
;
}
app/modules/u8g.c
View file @
c8037568
// Module for U8glib
// Module for U8glib
#include "
lualib
.h"
#include "
module
.h"
#include "lauxlib.h"
#include "lauxlib.h"
#include "platform.h"
#include "platform.h"
#include "auxmods.h"
#include "lrotable.h"
#include "c_stdlib.h"
#include "c_stdlib.h"
...
@@ -1027,11 +1025,7 @@ U8G_DISPLAY_TABLE_SPI
...
@@ -1027,11 +1025,7 @@ U8G_DISPLAY_TABLE_SPI
// Module function map
// Module function map
#define MIN_OPT_LEVEL 2
static
const
LUA_REG_TYPE
lu8g_display_map
[]
=
{
#include "lrodefs.h"
static
const
LUA_REG_TYPE
lu8g_display_map
[]
=
{
{
LSTRKEY
(
"begin"
),
LFUNCVAL
(
lu8g_begin
)
},
{
LSTRKEY
(
"begin"
),
LFUNCVAL
(
lu8g_begin
)
},
{
LSTRKEY
(
"drawBitmap"
),
LFUNCVAL
(
lu8g_drawBitmap
)
},
{
LSTRKEY
(
"drawBitmap"
),
LFUNCVAL
(
lu8g_drawBitmap
)
},
{
LSTRKEY
(
"drawBox"
),
LFUNCVAL
(
lu8g_drawBox
)
},
{
LSTRKEY
(
"drawBox"
),
LFUNCVAL
(
lu8g_drawBox
)
},
...
@@ -1083,82 +1077,38 @@ static const LUA_REG_TYPE lu8g_display_map[] =
...
@@ -1083,82 +1077,38 @@ static const LUA_REG_TYPE lu8g_display_map[] =
{
LSTRKEY
(
"undoRotation"
),
LFUNCVAL
(
lu8g_undoRotation
)
},
{
LSTRKEY
(
"undoRotation"
),
LFUNCVAL
(
lu8g_undoRotation
)
},
{
LSTRKEY
(
"undoScale"
),
LFUNCVAL
(
lu8g_undoScale
)
},
{
LSTRKEY
(
"undoScale"
),
LFUNCVAL
(
lu8g_undoScale
)
},
{
LSTRKEY
(
"__gc"
),
LFUNCVAL
(
lu8g_close_display
)
},
{
LSTRKEY
(
"__gc"
),
LFUNCVAL
(
lu8g_close_display
)
},
#if LUA_OPTIMIZE_MEMORY > 0
{
LSTRKEY
(
"__index"
),
LROVAL
(
lu8g_display_map
)
},
{
LSTRKEY
(
"__index"
),
LROVAL
(
lu8g_display_map
)
},
#endif
{
LNILKEY
,
LNILVAL
}
{
LNILKEY
,
LNILVAL
}
};
};
const
LUA_REG_TYPE
lu8g_map
[]
=
{
#undef U8G_DISPLAY_TABLE_ENTRY
#undef U8G_DISPLAY_TABLE_ENTRY
#define U8G_DISPLAY_TABLE_ENTRY(device) { LSTRKEY( #device ), LFUNCVAL ( lu8g_ ##device ) },
#undef U8G_FONT_TABLE_ENTRY
static
const
LUA_REG_TYPE
lu8g_map
[]
=
{
#define U8G_DISPLAY_TABLE_ENTRY(device) \
{ LSTRKEY( #device ), LFUNCVAL ( lu8g_ ##device ) },
U8G_DISPLAY_TABLE_I2C
U8G_DISPLAY_TABLE_I2C
U8G_DISPLAY_TABLE_SPI
U8G_DISPLAY_TABLE_SPI
// Register fonts
#if LUA_OPTIMIZE_MEMORY > 0
#define U8G_FONT_TABLE_ENTRY(font) \
{ LSTRKEY( #font ), LUDATA( (void *)(u8g_ ## font) ) },
// Register fonts
#undef U8G_FONT_TABLE_ENTRY
#define U8G_FONT_TABLE_ENTRY(font) { LSTRKEY( #font ), LUDATA( (void *)(u8g_ ## font) ) },
U8G_FONT_TABLE
U8G_FONT_TABLE
// Options for circle/ ellipse drawing
// Options for circle/ ellipse drawing
{
LSTRKEY
(
"DRAW_UPPER_RIGHT"
),
LNUMVAL
(
U8G_DRAW_UPPER_RIGHT
)
},
{
LSTRKEY
(
"DRAW_UPPER_RIGHT"
),
LNUMVAL
(
U8G_DRAW_UPPER_RIGHT
)
},
{
LSTRKEY
(
"DRAW_UPPER_LEFT"
),
LNUMVAL
(
U8G_DRAW_UPPER_LEFT
)
},
{
LSTRKEY
(
"DRAW_UPPER_LEFT"
),
LNUMVAL
(
U8G_DRAW_UPPER_LEFT
)
},
{
LSTRKEY
(
"DRAW_LOWER_RIGHT"
),
LNUMVAL
(
U8G_DRAW_LOWER_RIGHT
)
},
{
LSTRKEY
(
"DRAW_LOWER_RIGHT"
),
LNUMVAL
(
U8G_DRAW_LOWER_RIGHT
)
},
{
LSTRKEY
(
"DRAW_LOWER_LEFT"
),
LNUMVAL
(
U8G_DRAW_LOWER_LEFT
)
},
{
LSTRKEY
(
"DRAW_LOWER_LEFT"
),
LNUMVAL
(
U8G_DRAW_LOWER_LEFT
)
},
{
LSTRKEY
(
"DRAW_ALL"
),
LNUMVAL
(
U8G_DRAW_ALL
)
},
{
LSTRKEY
(
"DRAW_ALL"
),
LNUMVAL
(
U8G_DRAW_ALL
)
},
// Display modes
// Display modes
{
LSTRKEY
(
"MODE_BW"
),
LNUMVAL
(
U8G_MODE_BW
)
},
{
LSTRKEY
(
"MODE_BW"
),
LNUMVAL
(
U8G_MODE_BW
)
},
{
LSTRKEY
(
"MODE_GRAY2BIT"
),
LNUMVAL
(
U8G_MODE_GRAY2BIT
)
},
{
LSTRKEY
(
"MODE_GRAY2BIT"
),
LNUMVAL
(
U8G_MODE_GRAY2BIT
)
},
{
LSTRKEY
(
"__metatable"
),
LROVAL
(
lu8g_map
)
},
{
LSTRKEY
(
"__metatable"
),
LROVAL
(
lu8g_map
)
},
#endif
{
LNILKEY
,
LNILVAL
}
{
LNILKEY
,
LNILVAL
}
};
};
LUALIB_API
int
luaopen_u8g
(
lua_State
*
L
)
int
luaopen_u8g
(
lua_State
*
L
)
{
{
#if LUA_OPTIMIZE_MEMORY > 0
luaL_rometatable
(
L
,
"u8g.display"
,
(
void
*
)
lu8g_display_map
);
// create metatable
luaL_rometatable
(
L
,
"u8g.display"
,
(
void
*
)
lu8g_display_map
);
// create metatable
return
0
;
return
0
;
#else // #if LUA_OPTIMIZE_MEMORY > 0
int
n
;
luaL_register
(
L
,
AUXLIB_U8G
,
lu8g_map
);
// Set it as its own metatable
lua_pushvalue
(
L
,
-
1
);
lua_setmetatable
(
L
,
-
2
);
// Module constants
// Register fonts
#undef U8G_FONT_TABLE_ENTRY
#define U8G_FONT_TABLE_ENTRY(font) MOD_REG_LUDATA( L, #font, (void *)(u8g_ ## font) );
U8G_FONT_TABLE
// Options for circle/ ellipse drawing
MOD_REG_NUMBER
(
L
,
"DRAW_UPPER_RIGHT"
,
U8G_DRAW_UPPER_RIGHT
);
MOD_REG_NUMBER
(
L
,
"DRAW_UPPER_LEFT"
,
U8G_DRAW_UPPER_LEFT
);
MOD_REG_NUMBER
(
L
,
"DRAW_LOWER_RIGHT"
,
U8G_DRAW_LOWER_RIGHT
);
MOD_REG_NUMBER
(
L
,
"DRAW_LOWER_LEFT"
,
U8G_DRAW_LOWER_LEFT
);
MOD_REG_NUMBER
(
L
,
"DRAW_ALL"
,
U8G_DRAW_ALL
);
// Display modes
MOD_REG_NUMBER
(
L
,
"MODE_BW"
,
U8G_MODE_BW
);
MOD_REG_NUMBER
(
L
,
"MODE_GRAY2BIT"
,
U8G_MODE_GRAY2BIT
);
// create metatable
luaL_newmetatable
(
L
,
"u8g.display"
);
// metatable.__index = metatable
lua_pushliteral
(
L
,
"__index"
);
lua_pushvalue
(
L
,
-
2
);
lua_rawset
(
L
,
-
3
);
// Setup the methods inside metatable
luaL_register
(
L
,
NULL
,
u8g_display_map
);
return
1
;
#endif // #if LUA_OPTIMIZE_MEMORY > 0
}
}
NODEMCU_MODULE
(
U8G
,
"u8g"
,
lu8g_map
,
luaopen_u8g
);
app/modules/uart.c
View file @
c8037568
// Module for interfacing with serial
// Module for interfacing with serial
//#include "lua.h"
#include "module.h"
#include "lualib.h"
#include "lauxlib.h"
#include "lauxlib.h"
#include "platform.h"
#include "platform.h"
#include "auxmods.h"
#include "lrotable.h"
#include "c_types.h"
#include "c_types.h"
#include "c_string.h"
#include "c_string.h"
...
@@ -158,29 +155,18 @@ static int uart_write( lua_State* L )
...
@@ -158,29 +155,18 @@ static int uart_write( lua_State* L )
}
}
// Module function map
// Module function map
#define MIN_OPT_LEVEL 2
static
const
LUA_REG_TYPE
uart_map
[]
=
{
#include "lrodefs.h"
const
LUA_REG_TYPE
uart_map
[]
=
{
{
LSTRKEY
(
"setup"
),
LFUNCVAL
(
uart_setup
)
},
{
LSTRKEY
(
"setup"
),
LFUNCVAL
(
uart_setup
)
},
{
LSTRKEY
(
"write"
),
LFUNCVAL
(
uart_write
)
},
{
LSTRKEY
(
"write"
),
LFUNCVAL
(
uart_write
)
},
{
LSTRKEY
(
"on"
),
LFUNCVAL
(
uart_on
)
},
{
LSTRKEY
(
"on"
),
LFUNCVAL
(
uart_on
)
},
{
LSTRKEY
(
"alt"
),
LFUNCVAL
(
uart_alt
)
},
{
LSTRKEY
(
"alt"
),
LFUNCVAL
(
uart_alt
)
},
{
LSTRKEY
(
"STOPBITS_1"
),
LNUMVAL
(
PLATFORM_UART_STOPBITS_1
)
},
#if LUA_OPTIMIZE_MEMORY > 0
{
LSTRKEY
(
"STOPBITS_1_5"
),
LNUMVAL
(
PLATFORM_UART_STOPBITS_1_5
)
},
{
LSTRKEY
(
"STOPBITS_2"
),
LNUMVAL
(
PLATFORM_UART_STOPBITS_2
)
},
#endif
{
LSTRKEY
(
"PARITY_NONE"
),
LNUMVAL
(
PLATFORM_UART_PARITY_NONE
)
},
{
LSTRKEY
(
"PARITY_EVEN"
),
LNUMVAL
(
PLATFORM_UART_PARITY_EVEN
)
},
{
LSTRKEY
(
"PARITY_ODD"
),
LNUMVAL
(
PLATFORM_UART_PARITY_ODD
)
},
{
LNILKEY
,
LNILVAL
}
{
LNILKEY
,
LNILVAL
}
};
};
LUALIB_API
int
luaopen_uart
(
lua_State
*
L
)
NODEMCU_MODULE
(
UART
,
"uart"
,
uart_map
,
NULL
);
{
#if LUA_OPTIMIZE_MEMORY > 0
return
0
;
#else // #if LUA_OPTIMIZE_MEMORY > 0
luaL_register
(
L
,
AUXLIB_UART
,
uart_map
);
// Add constants
return
1
;
#endif // #if LUA_OPTIMIZE_MEMORY > 0
}
app/modules/ucg.c
View file @
c8037568
// Module for Ucglib
// Module for Ucglib
#include "
lualib
.h"
#include "
module
.h"
#include "lauxlib.h"
#include "lauxlib.h"
#include "platform.h"
#include "platform.h"
#include "auxmods.h"
#include "lrotable.h"
#include "c_stdlib.h"
#include "c_stdlib.h"
...
@@ -404,7 +402,7 @@ static int lucg_getHeight( lua_State *L )
...
@@ -404,7 +402,7 @@ static int lucg_getHeight( lua_State *L )
return
1
;
return
1
;
}
}
// Lua: width = ucg.getStrWidth( self )
// Lua: width = ucg.getStrWidth( self
, string
)
static
int
lucg_getStrWidth
(
lua_State
*
L
)
static
int
lucg_getStrWidth
(
lua_State
*
L
)
{
{
lucg_userdata_t
*
lud
;
lucg_userdata_t
*
lud
;
...
@@ -412,7 +410,7 @@ static int lucg_getStrWidth( lua_State *L )
...
@@ -412,7 +410,7 @@ static int lucg_getStrWidth( lua_State *L )
if
((
lud
=
get_lud
(
L
))
==
NULL
)
if
((
lud
=
get_lud
(
L
))
==
NULL
)
return
0
;
return
0
;
const
char
*
s
=
luaL_checkstring
(
L
,
(
1
+
3
)
+
1
);
const
char
*
s
=
luaL_checkstring
(
L
,
2
);
if
(
s
==
NULL
)
if
(
s
==
NULL
)
return
0
;
return
0
;
...
@@ -876,9 +874,6 @@ UCG_DISPLAY_TABLE
...
@@ -876,9 +874,6 @@ UCG_DISPLAY_TABLE
// Module function map
// Module function map
#define MIN_OPT_LEVEL 2
#include "lrodefs.h"
static
const
LUA_REG_TYPE
lucg_display_map
[]
=
static
const
LUA_REG_TYPE
lucg_display_map
[]
=
{
{
{
LSTRKEY
(
"begin"
),
LFUNCVAL
(
lucg_begin
)
},
{
LSTRKEY
(
"begin"
),
LFUNCVAL
(
lucg_begin
)
},
...
@@ -926,20 +921,16 @@ static const LUA_REG_TYPE lucg_display_map[] =
...
@@ -926,20 +921,16 @@ static const LUA_REG_TYPE lucg_display_map[] =
{
LSTRKEY
(
"undoScale"
),
LFUNCVAL
(
lucg_undoScale
)
},
{
LSTRKEY
(
"undoScale"
),
LFUNCVAL
(
lucg_undoScale
)
},
{
LSTRKEY
(
"__gc"
),
LFUNCVAL
(
lucg_close_display
)
},
{
LSTRKEY
(
"__gc"
),
LFUNCVAL
(
lucg_close_display
)
},
#if LUA_OPTIMIZE_MEMORY > 0
{
LSTRKEY
(
"__index"
),
LROVAL
(
lucg_display_map
)
},
{
LSTRKEY
(
"__index"
),
LROVAL
(
lucg_display_map
)
},
#endif
{
LNILKEY
,
LNILVAL
}
{
LNILKEY
,
LNILVAL
}
};
};
const
LUA_REG_TYPE
lucg_map
[]
=
static
const
LUA_REG_TYPE
lucg_map
[]
=
{
{
#undef UCG_DISPLAY_TABLE_ENTRY
#undef UCG_DISPLAY_TABLE_ENTRY
#define UCG_DISPLAY_TABLE_ENTRY(binding, device, extension) { LSTRKEY( #binding ), LFUNCVAL ( lucg_ ##binding ) },
#define UCG_DISPLAY_TABLE_ENTRY(binding, device, extension) { LSTRKEY( #binding ), LFUNCVAL ( lucg_ ##binding ) },
UCG_DISPLAY_TABLE
UCG_DISPLAY_TABLE
#if LUA_OPTIMIZE_MEMORY > 0
// Register fonts
// Register fonts
#undef UCG_FONT_TABLE_ENTRY
#undef UCG_FONT_TABLE_ENTRY
#define UCG_FONT_TABLE_ENTRY(font) { LSTRKEY( #font ), LUDATA( (void *)(ucg_ ## font) ) },
#define UCG_FONT_TABLE_ENTRY(font) { LSTRKEY( #font ), LUDATA( (void *)(ucg_ ## font) ) },
...
@@ -957,50 +948,13 @@ const LUA_REG_TYPE lucg_map[] =
...
@@ -957,50 +948,13 @@ const LUA_REG_TYPE lucg_map[] =
{
LSTRKEY
(
"DRAW_ALL"
),
LNUMVAL
(
UCG_DRAW_ALL
)
},
{
LSTRKEY
(
"DRAW_ALL"
),
LNUMVAL
(
UCG_DRAW_ALL
)
},
{
LSTRKEY
(
"__metatable"
),
LROVAL
(
lucg_map
)
},
{
LSTRKEY
(
"__metatable"
),
LROVAL
(
lucg_map
)
},
#endif
{
LNILKEY
,
LNILVAL
}
{
LNILKEY
,
LNILVAL
}
};
};
LUALIB_API
int
luaopen_ucg
(
lua_State
*
L
)
int
luaopen_ucg
(
lua_State
*
L
)
{
{
#if LUA_OPTIMIZE_MEMORY > 0
luaL_rometatable
(
L
,
"ucg.display"
,
(
void
*
)
lucg_display_map
);
// create metatable
luaL_rometatable
(
L
,
"ucg.display"
,
(
void
*
)
lucg_display_map
);
// create metatable
return
0
;
return
0
;
#else // #if LUA_OPTIMIZE_MEMORY > 0
int
n
;
luaL_register
(
L
,
AUXLIB_UCG
,
lucg_map
);
// Set it as its own metatable
lua_pushvalue
(
L
,
-
1
);
lua_setmetatable
(
L
,
-
2
);
// Module constants
// Register fonts
#undef UCG_FONT_TABLE_ENTRY
#define UCG_FONT_TABLE_ENTRY(font) MOD_REG_LUDATA( L, #font, (void *)(ucg_ ## font) );
UCG_FONT_TABLE
// Font modes
MOD_REG_NUMBER
(
L
,
"FONT_MODE_TRANSPARENT"
,
UCG_FONT_MODE_TRANSPARENT
);
MOD_REG_NUMBER
(
L
,
"FONT_MODE_SOLID"
,
UCG_FONT_MODE_SOLID
);
// Options for circle/ disc drawing
MOD_REG_NUMBER
(
L
,
"DRAW_UPPER_RIGHT"
,
UCG_DRAW_UPPER_RIGHT
);
MOD_REG_NUMBER
(
L
,
"DRAW_UPPER_LEFT"
,
UCG_DRAW_UPPER_LEFT
);
MOD_REG_NUMBER
(
L
,
"DRAW_LOWER_RIGHT"
,
UCG_DRAW_LOWER_RIGHT
);
MOD_REG_NUMBER
(
L
,
"DRAW_LOWER_LEFT"
,
UCG_DRAW_LOWER_LEFT
);
MOD_REG_NUMBER
(
L
,
"DRAW_ALL"
,
UCG_DRAW_ALL
);
// create metatable
luaL_newmetatable
(
L
,
"ucg.display"
);
// metatable.__index = metatable
lua_pushliteral
(
L
,
"__index"
);
lua_pushvalue
(
L
,
-
2
);
lua_rawset
(
L
,
-
3
);
// Setup the methods inside metatable
luaL_register
(
L
,
NULL
,
lucg_display_map
);
return
1
;
#endif // #if LUA_OPTIMIZE_MEMORY > 0
}
}
NODEMCU_MODULE
(
UCG
,
"ucg"
,
lucg_map
,
luaopen_ucg
);
app/modules/wifi.c
View file @
c8037568
// Module for interfacing with WIFI
// Module for interfacing with WIFI
//#include "lua.h"
#include "module.h"
#include "lualib.h"
#include "lauxlib.h"
#include "lauxlib.h"
#include "platform.h"
#include "platform.h"
#include "auxmods.h"
#include "lrotable.h"
#include "c_string.h"
#include "c_string.h"
#include "c_stdlib.h"
#include "c_stdlib.h"
...
@@ -1340,56 +1337,47 @@ static int wifi_ap_dhcp_stop( lua_State* L )
...
@@ -1340,56 +1337,47 @@ static int wifi_ap_dhcp_stop( lua_State* L )
}
}
// Module function map
// Module function map
#define MIN_OPT_LEVEL 2
static
const
LUA_REG_TYPE
wifi_station_map
[]
=
{
#include "lrodefs.h"
{
LSTRKEY
(
"getconfig"
),
LFUNCVAL
(
wifi_station_getconfig
)
},
static
const
LUA_REG_TYPE
wifi_station_map
[]
=
{
LSTRKEY
(
"config"
),
LFUNCVAL
(
wifi_station_config
)
},
{
{
LSTRKEY
(
"connect"
),
LFUNCVAL
(
wifi_station_connect4lua
)
},
{
LSTRKEY
(
"getconfig"
),
LFUNCVAL
(
wifi_station_getconfig
)
},
{
LSTRKEY
(
"disconnect"
),
LFUNCVAL
(
wifi_station_disconnect4lua
)
},
{
LSTRKEY
(
"config"
),
LFUNCVAL
(
wifi_station_config
)
},
{
LSTRKEY
(
"autoconnect"
),
LFUNCVAL
(
wifi_station_setauto
)
},
{
LSTRKEY
(
"connect"
),
LFUNCVAL
(
wifi_station_connect4lua
)
},
{
LSTRKEY
(
"getip"
),
LFUNCVAL
(
wifi_station_getip
)
},
{
LSTRKEY
(
"disconnect"
),
LFUNCVAL
(
wifi_station_disconnect4lua
)
},
{
LSTRKEY
(
"setip"
),
LFUNCVAL
(
wifi_station_setip
)
},
{
LSTRKEY
(
"autoconnect"
),
LFUNCVAL
(
wifi_station_setauto
)
},
{
LSTRKEY
(
"getbroadcast"
),
LFUNCVAL
(
wifi_station_getbroadcast
)
},
{
LSTRKEY
(
"getip"
),
LFUNCVAL
(
wifi_station_getip
)
},
{
LSTRKEY
(
"getmac"
),
LFUNCVAL
(
wifi_station_getmac
)
},
{
LSTRKEY
(
"setip"
),
LFUNCVAL
(
wifi_station_setip
)
},
{
LSTRKEY
(
"setmac"
),
LFUNCVAL
(
wifi_station_setmac
)
},
{
LSTRKEY
(
"getbroadcast"
),
LFUNCVAL
(
wifi_station_getbroadcast
)
},
{
LSTRKEY
(
"getap"
),
LFUNCVAL
(
wifi_station_listap
)
},
{
LSTRKEY
(
"getmac"
),
LFUNCVAL
(
wifi_station_getmac
)
},
{
LSTRKEY
(
"status"
),
LFUNCVAL
(
wifi_station_status
)
},
{
LSTRKEY
(
"setmac"
),
LFUNCVAL
(
wifi_station_setmac
)
},
{
LSTRKEY
(
"eventMonReg"
),
LFUNCVAL
(
wifi_station_event_mon_reg
)
},
{
LSTRKEY
(
"getap"
),
LFUNCVAL
(
wifi_station_listap
)
},
{
LSTRKEY
(
"eventMonStart"
),
LFUNCVAL
(
wifi_station_event_mon_start
)
},
{
LSTRKEY
(
"status"
),
LFUNCVAL
(
wifi_station_status
)
},
{
LSTRKEY
(
"eventMonStop"
),
LFUNCVAL
(
wifi_station_event_mon_stop
)
},
{
LSTRKEY
(
"eventMonReg"
),
LFUNCVAL
(
wifi_station_event_mon_reg
)
},
{
LSTRKEY
(
"eventMonStart"
),
LFUNCVAL
(
wifi_station_event_mon_start
)
},
{
LSTRKEY
(
"eventMonStop"
),
LFUNCVAL
(
wifi_station_event_mon_stop
)
},
{
LNILKEY
,
LNILVAL
}
{
LNILKEY
,
LNILVAL
}
};
};
static
const
LUA_REG_TYPE
wifi_ap_dhcp_map
[]
=
static
const
LUA_REG_TYPE
wifi_ap_dhcp_map
[]
=
{
{
{
LSTRKEY
(
"config"
),
LFUNCVAL
(
wifi_ap_dhcp_config
)
},
{
LSTRKEY
(
"config"
),
LFUNCVAL
(
wifi_ap_dhcp_config
)
},
{
LSTRKEY
(
"start"
),
LFUNCVAL
(
wifi_ap_dhcp_start
)
},
{
LSTRKEY
(
"start"
),
LFUNCVAL
(
wifi_ap_dhcp_start
)
},
{
LSTRKEY
(
"stop"
),
LFUNCVAL
(
wifi_ap_dhcp_stop
)
},
{
LSTRKEY
(
"stop"
),
LFUNCVAL
(
wifi_ap_dhcp_stop
)
},
{
LNILKEY
,
LNILVAL
}
{
LNILKEY
,
LNILVAL
}
};
};
static
const
LUA_REG_TYPE
wifi_ap_map
[]
=
static
const
LUA_REG_TYPE
wifi_ap_map
[]
=
{
{
{
LSTRKEY
(
"config"
),
LFUNCVAL
(
wifi_ap_config
)
},
{
LSTRKEY
(
"config"
),
LFUNCVAL
(
wifi_ap_config
)
},
{
LSTRKEY
(
"getip"
),
LFUNCVAL
(
wifi_ap_getip
)
},
{
LSTRKEY
(
"getip"
),
LFUNCVAL
(
wifi_ap_getip
)
},
{
LSTRKEY
(
"setip"
),
LFUNCVAL
(
wifi_ap_setip
)
},
{
LSTRKEY
(
"setip"
),
LFUNCVAL
(
wifi_ap_setip
)
},
{
LSTRKEY
(
"getbroadcast"
),
LFUNCVAL
(
wifi_ap_getbroadcast
)
},
{
LSTRKEY
(
"getbroadcast"
),
LFUNCVAL
(
wifi_ap_getbroadcast
)
},
{
LSTRKEY
(
"getmac"
),
LFUNCVAL
(
wifi_ap_getmac
)
},
{
LSTRKEY
(
"getmac"
),
LFUNCVAL
(
wifi_ap_getmac
)
},
{
LSTRKEY
(
"setmac"
),
LFUNCVAL
(
wifi_ap_setmac
)
},
{
LSTRKEY
(
"setmac"
),
LFUNCVAL
(
wifi_ap_setmac
)
},
{
LSTRKEY
(
"getclient"
),
LFUNCVAL
(
wifi_ap_listclient
)
},
{
LSTRKEY
(
"getclient"
),
LFUNCVAL
(
wifi_ap_listclient
)
},
{
LSTRKEY
(
"getconfig"
),
LFUNCVAL
(
wifi_ap_getconfig
)
},
{
LSTRKEY
(
"getconfig"
),
LFUNCVAL
(
wifi_ap_getconfig
)
},
#if LUA_OPTIMIZE_MEMORY > 0
{
LSTRKEY
(
"dhcp"
),
LROVAL
(
wifi_ap_dhcp_map
)
},
{
LSTRKEY
(
"dhcp"
),
LROVAL
(
wifi_ap_dhcp_map
)
},
//{ LSTRKEY( "__metatable" ), LROVAL( wifi_ap_map ) },
// { LSTRKEY( "__metatable" ), LROVAL( wifi_ap_map ) },
#endif
{
LNILKEY
,
LNILVAL
}
{
LNILKEY
,
LNILVAL
}
};
};
const
LUA_REG_TYPE
wifi_map
[]
=
static
const
LUA_REG_TYPE
wifi_map
[]
=
{
{
{
LSTRKEY
(
"setmode"
),
LFUNCVAL
(
wifi_setmode
)
},
{
LSTRKEY
(
"setmode"
),
LFUNCVAL
(
wifi_setmode
)
},
{
LSTRKEY
(
"getmode"
),
LFUNCVAL
(
wifi_getmode
)
},
{
LSTRKEY
(
"getmode"
),
LFUNCVAL
(
wifi_getmode
)
},
{
LSTRKEY
(
"getchannel"
),
LFUNCVAL
(
wifi_getchannel
)
},
{
LSTRKEY
(
"getchannel"
),
LFUNCVAL
(
wifi_getchannel
)
},
...
@@ -1399,7 +1387,7 @@ const LUA_REG_TYPE wifi_map[] =
...
@@ -1399,7 +1387,7 @@ const LUA_REG_TYPE wifi_map[] =
{
LSTRKEY
(
"startsmart"
),
LFUNCVAL
(
wifi_start_smart
)
},
{
LSTRKEY
(
"startsmart"
),
LFUNCVAL
(
wifi_start_smart
)
},
{
LSTRKEY
(
"stopsmart"
),
LFUNCVAL
(
wifi_exit_smart
)
},
{
LSTRKEY
(
"stopsmart"
),
LFUNCVAL
(
wifi_exit_smart
)
},
{
LSTRKEY
(
"sleeptype"
),
LFUNCVAL
(
wifi_sleeptype
)
},
{
LSTRKEY
(
"sleeptype"
),
LFUNCVAL
(
wifi_sleeptype
)
},
#if LUA_OPTIMIZE_MEMORY > 0
{
LSTRKEY
(
"sta"
),
LROVAL
(
wifi_station_map
)
},
{
LSTRKEY
(
"sta"
),
LROVAL
(
wifi_station_map
)
},
{
LSTRKEY
(
"ap"
),
LROVAL
(
wifi_ap_map
)
},
{
LSTRKEY
(
"ap"
),
LROVAL
(
wifi_ap_map
)
},
...
@@ -1417,7 +1405,7 @@ const LUA_REG_TYPE wifi_map[] =
...
@@ -1417,7 +1405,7 @@ const LUA_REG_TYPE wifi_map[] =
{
LSTRKEY
(
"MODEM_SLEEP"
),
LNUMVAL
(
MODEM_SLEEP_T
)
},
{
LSTRKEY
(
"MODEM_SLEEP"
),
LNUMVAL
(
MODEM_SLEEP_T
)
},
{
LSTRKEY
(
"OPEN"
),
LNUMVAL
(
AUTH_OPEN
)
},
{
LSTRKEY
(
"OPEN"
),
LNUMVAL
(
AUTH_OPEN
)
},
//
{ LSTRKEY( "WEP" ), LNUMVAL( AUTH_WEP ) },
//{ LSTRKEY( "WEP" ),
LNUMVAL( AUTH_WEP ) },
{
LSTRKEY
(
"WPA_PSK"
),
LNUMVAL
(
AUTH_WPA_PSK
)
},
{
LSTRKEY
(
"WPA_PSK"
),
LNUMVAL
(
AUTH_WPA_PSK
)
},
{
LSTRKEY
(
"WPA2_PSK"
),
LNUMVAL
(
AUTH_WPA2_PSK
)
},
{
LSTRKEY
(
"WPA2_PSK"
),
LNUMVAL
(
AUTH_WPA2_PSK
)
},
{
LSTRKEY
(
"WPA_WPA2_PSK"
),
LNUMVAL
(
AUTH_WPA_WPA2_PSK
)
},
{
LSTRKEY
(
"WPA_WPA2_PSK"
),
LNUMVAL
(
AUTH_WPA_WPA2_PSK
)
},
...
@@ -1430,58 +1418,7 @@ const LUA_REG_TYPE wifi_map[] =
...
@@ -1430,58 +1418,7 @@ const LUA_REG_TYPE wifi_map[] =
{
LSTRKEY
(
"STA_GOTIP"
),
LNUMVAL
(
STATION_GOT_IP
)
},
{
LSTRKEY
(
"STA_GOTIP"
),
LNUMVAL
(
STATION_GOT_IP
)
},
{
LSTRKEY
(
"__metatable"
),
LROVAL
(
wifi_map
)
},
{
LSTRKEY
(
"__metatable"
),
LROVAL
(
wifi_map
)
},
#endif
{
LNILKEY
,
LNILVAL
}
{
LNILKEY
,
LNILVAL
}
};
};
LUALIB_API
int
luaopen_wifi
(
lua_State
*
L
)
NODEMCU_MODULE
(
WIFI
,
"wifi"
,
wifi_map
,
NULL
);
{
#if LUA_OPTIMIZE_MEMORY > 0
return
0
;
#else // #if LUA_OPTIMIZE_MEMORY > 0
luaL_register
(
L
,
AUXLIB_WIFI
,
wifi_map
);
// Set it as its own metatable
lua_pushvalue
(
L
,
-
1
);
lua_setmetatable
(
L
,
-
2
);
// Module constants
// MOD_REG_NUMBER( L, "NULLMODE", NULL_MODE );
MOD_REG_NUMBER
(
L
,
"STATION"
,
STATION_MODE
);
MOD_REG_NUMBER
(
L
,
"SOFTAP"
,
SOFTAP_MODE
);
MOD_REG_NUMBER
(
L
,
"STATIONAP"
,
STATIONAP_MODE
);
MOD_REG_NUMBER
(
L
,
"NONE_SLEEP"
,
NONE_SLEEP_T
);
MOD_REG_NUMBER
(
L
,
"LIGHT_SLEEP"
,
LIGHT_SLEEP_T
);
MOD_REG_NUMBER
(
L
,
"MODEM_SLEEP"
,
MODEM_SLEEP_T
);
MOD_REG_NUMBER
(
L
,
"OPEN"
,
AUTH_OPEN
);
// MOD_REG_NUMBER( L, "WEP", AUTH_WEP );
MOD_REG_NUMBER
(
L
,
"WPA_PSK"
,
AUTH_WPA_PSK
);
MOD_REG_NUMBER
(
L
,
"WPA2_PSK"
,
AUTH_WPA2_PSK
);
MOD_REG_NUMBER
(
L
,
"WPA_WPA2_PSK"
,
AUTH_WPA_WPA2_PSK
);
// MOD_REG_NUMBER( L, "STA_IDLE", STATION_IDLE );
// MOD_REG_NUMBER( L, "STA_CONNECTING", STATION_CONNECTING );
// MOD_REG_NUMBER( L, "STA_WRONGPWD", STATION_WRONG_PASSWORD );
// MOD_REG_NUMBER( L, "STA_APNOTFOUND", STATION_NO_AP_FOUND );
// MOD_REG_NUMBER( L, "STA_FAIL", STATION_CONNECT_FAIL );
// MOD_REG_NUMBER( L, "STA_GOTIP", STATION_GOT_IP );
// Setup the new tables (station and ap) inside wifi
lua_newtable
(
L
);
luaL_register
(
L
,
NULL
,
wifi_station_map
);
lua_setfield
(
L
,
-
2
,
"sta"
);
lua_newtable
(
L
);
luaL_register
(
L
,
NULL
,
wifi_ap_map
);
lua_setfield
(
L
,
-
2
,
"ap"
);
// Setup the new table (dhcp) inside ap
lua_newtable
(
L
);
luaL_register
(
L
,
NULL
,
wifi_ap_dhcp_map
);
lua_setfield
(
L
,
-
1
,
"dhcp"
);
return
1
;
#endif // #if LUA_OPTIMIZE_MEMORY > 0
}
app/modules/ws2801.c
View file @
c8037568
#include "
lualib
.h"
#include "
module
.h"
#include "lauxlib.h"
#include "lauxlib.h"
#include "platform.h"
#include "platform.h"
#include "auxmods.h"
#include "lrotable.h"
#include "c_stdlib.h"
#include "c_stdlib.h"
#include "c_string.h"
#include "c_string.h"
...
@@ -124,17 +122,11 @@ static int ICACHE_FLASH_ATTR ws2801_writergb(lua_State* L) {
...
@@ -124,17 +122,11 @@ static int ICACHE_FLASH_ATTR ws2801_writergb(lua_State* L) {
return
0
;
return
0
;
}
}
#define MIN_OPT_LEVEL 2
static
const
LUA_REG_TYPE
ws2801_map
[]
=
#include "lrodefs.h"
const
LUA_REG_TYPE
ws2801_map
[]
=
{
{
{
LSTRKEY
(
"write"
),
LFUNCVAL
(
ws2801_writergb
)},
{
LSTRKEY
(
"write"
),
LFUNCVAL
(
ws2801_writergb
)},
{
LSTRKEY
(
"init"
),
LFUNCVAL
(
ws2801_init_lua
)},
{
LSTRKEY
(
"init"
),
LFUNCVAL
(
ws2801_init_lua
)},
{
LNILKEY
,
LNILVAL
}
{
LNILKEY
,
LNILVAL
}
};
};
LUALIB_API
int
luaopen_ws2801
(
lua_State
*
L
)
{
NODEMCU_MODULE
(
WS2801
,
"ws2801"
,
ws2801_map
,
NULL
);
LREGISTER
(
L
,
"ws2801"
,
ws2801_map
);
return
1
;
}
app/modules/ws2812.c
View file @
c8037568
#include "
lualib
.h"
#include "
module
.h"
#include "lauxlib.h"
#include "lauxlib.h"
#include "platform.h"
#include "platform.h"
#include "auxmods.h"
#include "lrotable.h"
#include "c_stdlib.h"
#include "c_stdlib.h"
#include "c_string.h"
#include "c_string.h"
#include "user_interface.h"
#include "user_interface.h"
...
@@ -127,17 +125,16 @@ static int ICACHE_FLASH_ATTR ws2812_writegrb(lua_State* L) {
...
@@ -127,17 +125,16 @@ static int ICACHE_FLASH_ATTR ws2812_writegrb(lua_State* L) {
return
0
;
return
0
;
}
}
#define MIN_OPT_LEVEL 2
static
const
LUA_REG_TYPE
ws2812_map
[]
=
#include "lrodefs.h"
const
LUA_REG_TYPE
ws2812_map
[]
=
{
{
{
LSTRKEY
(
"writergb"
),
LFUNCVAL
(
ws2812_writergb
)},
{
LSTRKEY
(
"writergb"
),
LFUNCVAL
(
ws2812_writergb
)},
{
LSTRKEY
(
"write"
),
LFUNCVAL
(
ws2812_writegrb
)},
{
LSTRKEY
(
"write"
),
LFUNCVAL
(
ws2812_writegrb
)},
{
LNILKEY
,
LNILVAL
}
{
LNILKEY
,
LNILVAL
}
};
};
LUALIB_API
int
luaopen_ws2812
(
lua_State
*
L
)
{
int
luaopen_ws2812
(
lua_State
*
L
)
{
// TODO: Make sure that the GPIO system is initialized
// TODO: Make sure that the GPIO system is initialized
LREGISTER
(
L
,
"ws2812"
,
ws2812_map
);
return
0
;
return
1
;
}
}
NODEMCU_MODULE
(
WS2812
,
"ws2812"
,
ws2812_map
,
luaopen_ws2812
);
app/platform/common.c
View file @
c8037568
...
@@ -102,15 +102,14 @@ extern char _flash_used_end[];
...
@@ -102,15 +102,14 @@ extern char _flash_used_end[];
// Return the sector number, as well as the start and end address of the sector
// Return the sector number, as well as the start and end address of the sector
static
uint32_t
flashh_find_sector
(
uint32_t
address
,
uint32_t
*
pstart
,
uint32_t
*
pend
)
static
uint32_t
flashh_find_sector
(
uint32_t
address
,
uint32_t
*
pstart
,
uint32_t
*
pend
)
{
{
address
-=
INTERNAL_FLASH_START_ADDRESS
;
#ifdef INTERNAL_FLASH_SECTOR_SIZE
#ifdef INTERNAL_FLASH_SECTOR_SIZE
// All the sectors in the flash have the same size, so just align the address
// All the sectors in the flash have the same size, so just align the address
uint32_t
sect_id
=
address
/
INTERNAL_FLASH_SECTOR_SIZE
;
uint32_t
sect_id
=
address
/
INTERNAL_FLASH_SECTOR_SIZE
;
if
(
pstart
)
if
(
pstart
)
*
pstart
=
sect_id
*
INTERNAL_FLASH_SECTOR_SIZE
+
INTERNAL_FLASH_START_ADDRESS
;
*
pstart
=
sect_id
*
INTERNAL_FLASH_SECTOR_SIZE
;
if
(
pend
)
if
(
pend
)
*
pend
=
(
sect_id
+
1
)
*
INTERNAL_FLASH_SECTOR_SIZE
+
INTERNAL_FLASH_START_ADDRESS
-
1
;
*
pend
=
(
sect_id
+
1
)
*
INTERNAL_FLASH_SECTOR_SIZE
-
1
;
return
sect_id
;
return
sect_id
;
#else // #ifdef INTERNAL_FLASH_SECTOR_SIZE
#else // #ifdef INTERNAL_FLASH_SECTOR_SIZE
// The flash has blocks of different size
// The flash has blocks of different size
...
@@ -121,9 +120,9 @@ static uint32_t flashh_find_sector( uint32_t address, uint32_t *pstart, uint32_t
...
@@ -121,9 +120,9 @@ static uint32_t flashh_find_sector( uint32_t address, uint32_t *pstart, uint32_t
while
(
(
total
<=
address
)
&&
(
i
<
sizeof
(
flash_sect_size
)
/
sizeof
(
uint32_t
)
)
)
while
(
(
total
<=
address
)
&&
(
i
<
sizeof
(
flash_sect_size
)
/
sizeof
(
uint32_t
)
)
)
total
+=
flash_sect_size
[
i
++
];
total
+=
flash_sect_size
[
i
++
];
if
(
pstart
)
if
(
pstart
)
*
pstart
=
(
total
-
flash_sect_size
[
i
-
1
]
)
+
INTERNAL_FLASH_START_ADDRESS
;
*
pstart
=
(
total
-
flash_sect_size
[
i
-
1
]
);
if
(
pend
)
if
(
pend
)
*
pend
=
total
+
INTERNAL_FLASH_START_ADDRESS
-
1
;
*
pend
=
total
-
1
;
return
i
-
1
;
return
i
-
1
;
#endif // #ifdef INTERNAL_FLASH_SECTOR_SIZE
#endif // #ifdef INTERNAL_FLASH_SECTOR_SIZE
}
}
...
@@ -150,13 +149,12 @@ uint32_t platform_flash_get_first_free_block_address( uint32_t *psect )
...
@@ -150,13 +149,12 @@ uint32_t platform_flash_get_first_free_block_address( uint32_t *psect )
uint32_t
start
,
end
,
sect
;
uint32_t
start
,
end
,
sect
;
NODE_DBG
(
"_flash_used_end:%08x
\n
"
,
(
uint32_t
)
_flash_used_end
);
NODE_DBG
(
"_flash_used_end:%08x
\n
"
,
(
uint32_t
)
_flash_used_end
);
if
(
_flash_used_end
>
0
){
// find the used sector
if
(
_flash_used_end
>
0
){
// find the used sector
// sect = flashh_find_sector( ( uint32_t )flash_used_size + INTERNAL_FLASH_START_ADDRESS - 1, NULL, &end );
sect
=
flashh_find_sector
(
platform_flash_mapped2phys
(
(
uint32_t
)
_flash_used_end
-
1
),
NULL
,
&
end
);
sect
=
flashh_find_sector
(
(
uint32_t
)
_flash_used_end
-
1
,
NULL
,
&
end
);
if
(
psect
)
if
(
psect
)
*
psect
=
sect
+
1
;
*
psect
=
sect
+
1
;
return
end
+
1
;
return
end
+
1
;
}
else
{
}
else
{
sect
=
flashh_find_sector
(
INTERNAL_FLASH_START_ADDRESS
,
&
start
,
NULL
);
// find the first free sector
sect
=
flashh_find_sector
(
0
,
&
start
,
NULL
);
// find the first free sector
if
(
psect
)
if
(
psect
)
*
psect
=
sect
;
*
psect
=
sect
;
return
start
;
return
start
;
...
...
app/platform/cpu_esp8266.h
View file @
c8037568
...
@@ -53,7 +53,7 @@
...
@@ -53,7 +53,7 @@
#define INTERNAL_FLASH_READ_UNIT_SIZE 4
#define INTERNAL_FLASH_READ_UNIT_SIZE 4
#define INTERNAL_FLASH_SIZE ( (SYS_PARAM_SEC_START) * INTERNAL_FLASH_SECTOR_SIZE )
#define INTERNAL_FLASH_SIZE ( (SYS_PARAM_SEC_START) * INTERNAL_FLASH_SECTOR_SIZE )
#define INTERNAL_FLASH_
START
_ADDRESS 0x40200000
#define INTERNAL_FLASH_
MAPPED
_ADDRESS 0x40200000
// SpiFlashOpResult spi_flash_erase_sector(uint16 sec);
// SpiFlashOpResult spi_flash_erase_sector(uint16 sec);
// SpiFlashOpResult spi_flash_write(uint32 des_addr, uint32 *src_addr, uint32 size);
// SpiFlashOpResult spi_flash_write(uint32 des_addr, uint32 *src_addr, uint32 size);
...
@@ -68,4 +68,9 @@
...
@@ -68,4 +68,9 @@
#define flash_read spi_flash_read
#define flash_read spi_flash_read
#endif // defined(FLASH_SAFE_API)
#endif // defined(FLASH_SAFE_API)
#define CACHE_FLASH_CTRL_REG 0x3ff0000c
#define CACHE_FLASH_ACTIVE 0x00000100
#define CACHE_FLASH_MAPPED0 0x02000000
#define CACHE_FLASH_MAPPED1 0x00010000
#endif // #ifndef __CPU_ESP8266_H__
#endif // #ifndef __CPU_ESP8266_H__
app/platform/flash_api.c
View file @
c8037568
...
@@ -96,11 +96,6 @@ SpiFlashOpResult flash_safe_erase_sector(uint16 sec)
...
@@ -96,11 +96,6 @@ SpiFlashOpResult flash_safe_erase_sector(uint16 sec)
SPIFlashInfo
flash_rom_getinfo
(
void
)
SPIFlashInfo
flash_rom_getinfo
(
void
)
{
{
volatile
SPIFlashInfo
spi_flash_info
ICACHE_STORE_ATTR
;
volatile
SPIFlashInfo
spi_flash_info
ICACHE_STORE_ATTR
;
// Don't use it before cache read disabled
// FLASH_DISABLE_CACHE();
// spi_flash_info = *((SPIFlashInfo *)(FLASH_ADDRESS_START_MAP));
// FLASH_ENABLE_CACHE();
// Needn't safe mode.
spi_flash_read
(
0
,
(
uint32
*
)(
&
spi_flash_info
),
sizeof
(
spi_flash_info
));
spi_flash_read
(
0
,
(
uint32
*
)(
&
spi_flash_info
),
sizeof
(
spi_flash_info
));
return
spi_flash_info
;
return
spi_flash_info
;
}
}
...
...
app/platform/flash_api.h
View file @
c8037568
...
@@ -4,8 +4,6 @@
...
@@ -4,8 +4,6 @@
#include "user_config.h"
#include "user_config.h"
#include "cpu_esp8266.h"
#include "cpu_esp8266.h"
#define FLASH_ADDRESS_START_MAP (INTERNAL_FLASH_START_ADDRESS)
#define FLASH_SIZE_2MBIT (2 * 1024 * 1024)
#define FLASH_SIZE_2MBIT (2 * 1024 * 1024)
#define FLASH_SIZE_4MBIT (4 * 1024 * 1024)
#define FLASH_SIZE_4MBIT (4 * 1024 * 1024)
#define FLASH_SIZE_8MBIT (8 * 1024 * 1024)
#define FLASH_SIZE_8MBIT (8 * 1024 * 1024)
...
...
app/platform/platform.c
View file @
c8037568
...
@@ -222,8 +222,8 @@ uint32_t platform_uart_setup( unsigned id, uint32_t baud, int databits, int pari
...
@@ -222,8 +222,8 @@ uint32_t platform_uart_setup( unsigned id, uint32_t baud, int databits, int pari
switch
(
stopbits
)
switch
(
stopbits
)
{
{
case
PLATFORM_UART_STOPBITS_1
:
case
PLATFORM_UART_STOPBITS_1
_5
:
UartDev
.
stop_bits
=
ONE_STOP_BIT
;
UartDev
.
stop_bits
=
ONE_
HALF_
STOP_BIT
;
break
;
break
;
case
PLATFORM_UART_STOPBITS_2
:
case
PLATFORM_UART_STOPBITS_2
:
UartDev
.
stop_bits
=
TWO_STOP_BIT
;
UartDev
.
stop_bits
=
TWO_STOP_BIT
;
...
@@ -237,12 +237,15 @@ uint32_t platform_uart_setup( unsigned id, uint32_t baud, int databits, int pari
...
@@ -237,12 +237,15 @@ uint32_t platform_uart_setup( unsigned id, uint32_t baud, int databits, int pari
{
{
case
PLATFORM_UART_PARITY_EVEN
:
case
PLATFORM_UART_PARITY_EVEN
:
UartDev
.
parity
=
EVEN_BITS
;
UartDev
.
parity
=
EVEN_BITS
;
UartDev
.
exist_parity
=
STICK_PARITY_EN
;
break
;
break
;
case
PLATFORM_UART_PARITY_ODD
:
case
PLATFORM_UART_PARITY_ODD
:
UartDev
.
parity
=
ODD_BITS
;
UartDev
.
parity
=
ODD_BITS
;
UartDev
.
exist_parity
=
STICK_PARITY_EN
;
break
;
break
;
default:
default:
UartDev
.
parity
=
NONE_BITS
;
UartDev
.
parity
=
NONE_BITS
;
UartDev
.
exist_parity
=
STICK_PARITY_DIS
;
break
;
break
;
}
}
...
@@ -514,12 +517,11 @@ int platform_spi_transaction( uint8_t id, uint8_t cmd_bitlen, spi_data_type cmd_
...
@@ -514,12 +517,11 @@ int platform_spi_transaction( uint8_t id, uint8_t cmd_bitlen, spi_data_type cmd_
*/
*/
uint32_t
platform_s_flash_write
(
const
void
*
from
,
uint32_t
toaddr
,
uint32_t
size
)
uint32_t
platform_s_flash_write
(
const
void
*
from
,
uint32_t
toaddr
,
uint32_t
size
)
{
{
toaddr
-=
INTERNAL_FLASH_START_ADDRESS
;
SpiFlashOpResult
r
;
SpiFlashOpResult
r
;
const
uint32_t
blkmask
=
INTERNAL_FLASH_WRITE_UNIT_SIZE
-
1
;
const
uint32_t
blkmask
=
INTERNAL_FLASH_WRITE_UNIT_SIZE
-
1
;
uint32_t
*
apbuf
=
NULL
;
uint32_t
*
apbuf
=
NULL
;
uint32_t
fromaddr
=
(
uint32_t
)
from
;
uint32_t
fromaddr
=
(
uint32_t
)
from
;
if
(
(
fromaddr
&
blkmask
)
||
(
fromaddr
>=
INTERNAL_FLASH_
START
_ADDRESS
))
{
if
(
(
fromaddr
&
blkmask
)
||
(
fromaddr
>=
INTERNAL_FLASH_
MAPPED
_ADDRESS
))
{
apbuf
=
(
uint32_t
*
)
c_malloc
(
size
);
apbuf
=
(
uint32_t
*
)
c_malloc
(
size
);
if
(
!
apbuf
)
if
(
!
apbuf
)
return
0
;
return
0
;
...
@@ -532,7 +534,7 @@ uint32_t platform_s_flash_write( const void *from, uint32_t toaddr, uint32_t siz
...
@@ -532,7 +534,7 @@ uint32_t platform_s_flash_write( const void *from, uint32_t toaddr, uint32_t siz
if
(
SPI_FLASH_RESULT_OK
==
r
)
if
(
SPI_FLASH_RESULT_OK
==
r
)
return
size
;
return
size
;
else
{
else
{
NODE_ERR
(
"ERROR in flash_write: r=%d at %08X
\n
"
,
(
int
)
r
,
(
unsigned
)
toaddr
+
INTERNAL_FLASH_START_ADDRESS
);
NODE_ERR
(
"ERROR in flash_write: r=%d at %08X
\n
"
,
(
int
)
r
,
(
unsigned
)
toaddr
);
return
0
;
return
0
;
}
}
}
}
...
@@ -547,7 +549,6 @@ uint32_t platform_s_flash_read( void *to, uint32_t fromaddr, uint32_t size )
...
@@ -547,7 +549,6 @@ uint32_t platform_s_flash_read( void *to, uint32_t fromaddr, uint32_t size )
if
(
size
==
0
)
if
(
size
==
0
)
return
0
;
return
0
;
fromaddr
-=
INTERNAL_FLASH_START_ADDRESS
;
SpiFlashOpResult
r
;
SpiFlashOpResult
r
;
system_soft_wdt_feed
();
system_soft_wdt_feed
();
...
@@ -571,7 +572,7 @@ uint32_t platform_s_flash_read( void *to, uint32_t fromaddr, uint32_t size )
...
@@ -571,7 +572,7 @@ uint32_t platform_s_flash_read( void *to, uint32_t fromaddr, uint32_t size )
if
(
SPI_FLASH_RESULT_OK
==
r
)
if
(
SPI_FLASH_RESULT_OK
==
r
)
return
size
;
return
size
;
else
{
else
{
NODE_ERR
(
"ERROR in flash_read: r=%d at %08X
\n
"
,
(
int
)
r
,
(
unsigned
)
fromaddr
+
INTERNAL_FLASH_START_ADDRESS
);
NODE_ERR
(
"ERROR in flash_read: r=%d at %08X
\n
"
,
(
int
)
r
,
(
unsigned
)
fromaddr
);
return
0
;
return
0
;
}
}
}
}
...
@@ -581,3 +582,14 @@ int platform_flash_erase_sector( uint32_t sector_id )
...
@@ -581,3 +582,14 @@ int platform_flash_erase_sector( uint32_t sector_id )
system_soft_wdt_feed
();
system_soft_wdt_feed
();
return
flash_erase
(
sector_id
)
==
SPI_FLASH_RESULT_OK
?
PLATFORM_OK
:
PLATFORM_ERR
;
return
flash_erase
(
sector_id
)
==
SPI_FLASH_RESULT_OK
?
PLATFORM_OK
:
PLATFORM_ERR
;
}
}
uint32_t
platform_flash_mapped2phys
(
uint32_t
mapped_addr
)
{
uint32_t
cache_ctrl
=
READ_PERI_REG
(
CACHE_FLASH_CTRL_REG
);
if
(
!
(
cache_ctrl
&
CACHE_FLASH_ACTIVE
))
return
-
1
;
bool
b0
=
(
cache_ctrl
&
CACHE_FLASH_MAPPED0
)
?
1
:
0
;
bool
b1
=
(
cache_ctrl
&
CACHE_FLASH_MAPPED1
)
?
1
:
0
;
uint32_t
meg
=
(
b1
<<
1
)
|
b0
;
return
mapped_addr
-
INTERNAL_FLASH_MAPPED_ADDRESS
+
meg
*
0x100000
;
}
app/platform/platform.h
View file @
c8037568
...
@@ -119,19 +119,19 @@ int platform_spi_transaction( uint8_t id, uint8_t cmd_bitlen, spi_data_type cmd_
...
@@ -119,19 +119,19 @@ int platform_spi_transaction( uint8_t id, uint8_t cmd_bitlen, spi_data_type cmd_
// Parity
// Parity
enum
enum
{
{
PLATFORM_UART_PARITY_
EVEN
,
PLATFORM_UART_PARITY_
NONE
=
0
,
PLATFORM_UART_PARITY_
ODD
,
PLATFORM_UART_PARITY_
EVEN
=
1
,
PLATFORM_UART_PARITY_
NONE
,
PLATFORM_UART_PARITY_
ODD
=
2
,
PLATFORM_UART_PARITY_MARK
,
PLATFORM_UART_PARITY_MARK
=
3
,
PLATFORM_UART_PARITY_SPACE
PLATFORM_UART_PARITY_SPACE
=
4
};
};
// Stop bits
// Stop bits
enum
enum
{
{
PLATFORM_UART_STOPBITS_1
,
PLATFORM_UART_STOPBITS_1
=
1
,
PLATFORM_UART_STOPBITS_
1_5
,
PLATFORM_UART_STOPBITS_
2
=
2
,
PLATFORM_UART_STOPBITS_
2
PLATFORM_UART_STOPBITS_
1_5
=
3
};
};
// Flow control types (this is a bit mask, one can specify PLATFORM_UART_FLOW_RTS | PLATFORM_UART_FLOW_CTS )
// Flow control types (this is a bit mask, one can specify PLATFORM_UART_FLOW_RTS | PLATFORM_UART_FLOW_CTS )
...
@@ -237,10 +237,36 @@ uint32_t platform_s_flash_read( void *to, uint32_t fromaddr, uint32_t size );
...
@@ -237,10 +237,36 @@ uint32_t platform_s_flash_read( void *to, uint32_t fromaddr, uint32_t size );
uint32_t
platform_flash_get_num_sectors
(
void
);
uint32_t
platform_flash_get_num_sectors
(
void
);
int
platform_flash_erase_sector
(
uint32_t
sector_id
);
int
platform_flash_erase_sector
(
uint32_t
sector_id
);
/**
* Translated a mapped address to a physical flash address, based on the
* current flash cache mapping.
* @param mapped_addr Address to translate (>= INTERNAL_FLASH_MAPPED_ADDRESS)
* @return the corresponding physical flash address, or -1 if flash cache is
* not currently active.
* @see Cache_Read_Enable.
*/
uint32_t
platform_flash_mapped2phys
(
uint32_t
mapped_addr
);
// *****************************************************************************
// *****************************************************************************
// Allocator support
// Allocator support
void
*
platform_get_first_free_ram
(
unsigned
id
);
void
*
platform_get_first_free_ram
(
unsigned
id
);
void
*
platform_get_last_free_ram
(
unsigned
id
);
void
*
platform_get_last_free_ram
(
unsigned
id
);
// *****************************************************************************
// Helper macros
#define MOD_CHECK_ID( mod, id )\
if( !platform_ ## mod ## _exists( id ) )\
return luaL_error( L, #mod" %d does not exist", ( unsigned )id )
#define MOD_CHECK_TIMER( id )\
if( id == PLATFORM_TIMER_SYS_ID && !platform_timer_sys_available() )\
return luaL_error( L, "the system timer is not available on this platform" );\
if( !platform_timer_exists( id ) )\
return luaL_error( L, "timer %d does not exist", ( unsigned )id )\
#define MOD_CHECK_RES_ID( mod, id, resmod, resid )\
if( !platform_ ## mod ## _check_ ## resmod ## _id( id, resid ) )\
return luaL_error( L, #resmod" %d not valid with " #mod " %d", ( unsigned )resid, ( unsigned )id )
#endif
#endif
app/spiffs/spiffs.c
View file @
c8037568
...
@@ -51,9 +51,9 @@ void myspiffs_mount() {
...
@@ -51,9 +51,9 @@ void myspiffs_mount() {
#else
#else
cfg
.
phys_addr
=
(
u32_t
)
platform_flash_get_first_free_block_address
(
NULL
);
cfg
.
phys_addr
=
(
u32_t
)
platform_flash_get_first_free_block_address
(
NULL
);
#endif
#endif
cfg
.
phys_addr
+=
0x3
000
;
cfg
.
phys_addr
+=
0x3
FFF
;
cfg
.
phys_addr
&=
0xFFFFC000
;
// align to 4 sector.
cfg
.
phys_addr
&=
0xFFFFC000
;
// align to 4 sector.
cfg
.
phys_size
=
INTERNAL_FLASH_SIZE
-
(
(
u32_t
)
cfg
.
phys_addr
-
INTERNAL_FLASH_START_ADDRESS
);
cfg
.
phys_size
=
INTERNAL_FLASH_SIZE
-
(
(
u32_t
)
cfg
.
phys_addr
);
cfg
.
phys_erase_block
=
INTERNAL_FLASH_SECTOR_SIZE
;
// according to datasheet
cfg
.
phys_erase_block
=
INTERNAL_FLASH_SECTOR_SIZE
;
// according to datasheet
cfg
.
log_block_size
=
INTERNAL_FLASH_SECTOR_SIZE
;
// let us not complicate things
cfg
.
log_block_size
=
INTERNAL_FLASH_SECTOR_SIZE
;
// let us not complicate things
cfg
.
log_page_size
=
LOG_PAGE_SIZE
;
// as we said
cfg
.
log_page_size
=
LOG_PAGE_SIZE
;
// as we said
...
@@ -94,10 +94,10 @@ int myspiffs_format( void )
...
@@ -94,10 +94,10 @@ int myspiffs_format( void )
#else
#else
sect_first
=
(
u32_t
)
platform_flash_get_first_free_block_address
(
NULL
);
sect_first
=
(
u32_t
)
platform_flash_get_first_free_block_address
(
NULL
);
#endif
#endif
sect_first
+=
0x3
000
;
sect_first
+=
0x3
FFF
;
sect_first
&=
0xFFFFC000
;
// align to 4 sector.
sect_first
&=
0xFFFFC000
;
// align to 4 sector.
sect_first
=
platform_flash_get_sector_of_address
(
sect_first
);
sect_first
=
platform_flash_get_sector_of_address
(
sect_first
);
sect_last
=
INTERNAL_FLASH_SIZE
+
INTERNAL_FLASH_START_ADDRESS
-
4
;
sect_last
=
INTERNAL_FLASH_SIZE
-
SYS_PARAM_SEC_NUM
;
sect_last
=
platform_flash_get_sector_of_address
(
sect_last
);
sect_last
=
platform_flash_get_sector_of_address
(
sect_last
);
NODE_DBG
(
"sect_first: %x, sect_last: %x
\n
"
,
sect_first
,
sect_last
);
NODE_DBG
(
"sect_first: %x, sect_last: %x
\n
"
,
sect_first
,
sect_last
);
while
(
sect_first
<=
sect_last
)
while
(
sect_first
<=
sect_last
)
...
...
app/u8glib/README.md
0 → 100644
View file @
c8037568
##U8glib package
Ported from https://github.com/olikraus/u8glib
Here is black magic with ImageMagic package for image conversion:
```
bash
#!/bin/bash
mkdir
out
for
icon
in
*
png
;
do
convert
$icon
-depth
1 ./out/
$(
basename
$icon
.png
)
_1bpp.png
if
[[
"
$icon
"
==
*
"black"
*
]]
;
then
convert ./out/
$(
basename
$icon
.png
)
_1bpp.png
-background
white
-alpha
Background ./out/
$(
basename
$icon
.png
)
_1bpp.xbm
else
convert ./out/
$(
basename
$icon
.png
)
_1bpp.png
-background
black
-alpha
Background ./out/
$(
basename
$icon
.png
)
_1bpp.xbm
fi
cat
./out/
$(
basename
$icon
.png
)
_1bpp.xbm |
tr
'\n'
' '
|
tr
-d
" "
|sed
-e
s
'#^.*{##g'
|
sed
s
'#,}##'
|sed s
'/;//'
| xxd
-r
-p
>
./out/
$(
basename
$icon
.png
)
.xbm.mono
done
rm
out/
*
png out/
*
xbm
```
Convert all the png in the current folder and put resulting .mono to ./out
The convert binary is a part of ImageMagic package. You need to install it.
```
sudo apt-get install imagemagick
```
for Debian/Ubuntu.
\ No newline at end of file
Prev
1
2
3
4
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment