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
e7c29fe3
Commit
e7c29fe3
authored
Jul 18, 2019
by
Terry Ellison
Committed by
Marcel Stör
Jun 09, 2020
Browse files
Lua 5.1 to 5.3 realignement phase 1
parent
3d917850
Changes
44
Show whitespace changes
Inline
Side-by-side
.gdbinitlua
View file @
e7c29fe3
...
@@ -3,9 +3,9 @@ set pagination off
...
@@ -3,9 +3,9 @@ set pagination off
set print null-stop
set print null-stop
define prTS
define prTS
set $o = &(((TString *)($arg0))->tsv)
set $o = &(((TString *)(
(
$arg0)
.value)
)->tsv)
printf "Common header: next = %p, marked = 0x%01x\n", $o->next, $o->marked
printf "Common header: next = %p, marked = 0x%01x\n", $o->next, $o->marked
printf "String: hash = 0x%08x, len = %u : %s\n", $o->hash, $o->len, (char *)(
&
$o
[1]
)
printf "String: hash = 0x%08x, len = %u : %s\n", $o->hash, $o->len, (char *)($o
+1
)
end
end
define prTnodes
define prTnodes
...
@@ -24,6 +24,18 @@ define prTnodes
...
@@ -24,6 +24,18 @@ define prTnodes
set $i = $i +1
set $i = $i +1
end
end
end
end
define prTarray
set $o = (Table *)($arg0)
set $n = $o->sizearray
set $i = 0
while $i < $n
set $nd = ($o->array) + $i
prTV $nd
set $i = $i +1
end
end
define prTV
define prTV
if $arg0
if $arg0
set $type = ($arg0).tt
set $type = ($arg0).tt
...
@@ -78,6 +90,10 @@ define prTV
...
@@ -78,6 +90,10 @@ define prTV
end
end
if $type == 9
if $type == 9
# UserData
# UserData
set $o = &($val->gc.u.uv)
printf "Common header: next = %p, marked = 0x%01x\n", $o->next, $o->marked
printf "UD = %p Userdata: metatable = ", ($o+1))
print ($o)->metatable
end
end
if $type == 10
if $type == 10
# Thread
# Thread
...
...
app/Makefile
View file @
e7c29fe3
...
@@ -36,7 +36,6 @@ SUBDIRS= \
...
@@ -36,7 +36,6 @@ SUBDIRS= \
libc
\
libc
\
lua
\
lua
\
lwip
\
lwip
\
task
\
smart
\
smart
\
modules
\
modules
\
spiffs
\
spiffs
\
...
@@ -65,7 +64,6 @@ COMPONENTS_eagle.app.v6 = \
...
@@ -65,7 +64,6 @@ COMPONENTS_eagle.app.v6 = \
crypto/libcrypto.a
\
crypto/libcrypto.a
\
driver/libdriver.a
\
driver/libdriver.a
\
platform/libplatform.a
\
platform/libplatform.a
\
task/libtask.a
\
libc/liblibc.a
\
libc/liblibc.a
\
lua/liblua.a
\
lua/liblua.a
\
lwip/liblwip.a
\
lwip/liblwip.a
\
...
...
app/driver/Makefile
View file @
e7c29fe3
...
@@ -15,7 +15,7 @@ ifndef PDIR
...
@@ -15,7 +15,7 @@ ifndef PDIR
GEN_LIBS
=
libdriver.a
GEN_LIBS
=
libdriver.a
endif
endif
STD_CFLAGS
=
-std
=
gnu11
-Wimplicit
STD_CFLAGS
=
-std
=
gnu11
-Wimplicit
-Wall
#############################################################
#############################################################
# Configuration i.e. compile options etc.
# Configuration i.e. compile options etc.
...
...
app/driver/input.c
0 → 100644
View file @
e7c29fe3
#include "platform.h"
#include "driver/uart.h"
#include "driver/input.h"
#include <stdint.h>
#include "mem.h"
/**DEBUG**/
extern
void
dbg_printf
(
const
char
*
fmt
,
...)
__attribute__
((
format
(
printf
,
1
,
2
)));
static
void
input_handler
(
platform_task_param_t
flag
,
uint8
priority
);
static
struct
input_state
{
char
*
data
;
int
line_pos
;
size_t
len
;
const
char
*
prompt
;
uart_cb_t
uart_cb
;
platform_task_handle_t
input_sig
;
int
data_len
;
bool
run_input
;
bool
uart_echo
;
char
last_char
;
char
end_char
;
uint8
input_sig_flag
;
}
ins
=
{
0
};
#define NUL '\0'
#define BS '\010'
#define CR '\r'
#define LF '\n'
#define DEL 0x7f
#define BS_OVER "\010 \010"
#define sendStr(s) uart0_sendStr(s)
#define putc(c) uart0_putc(c)
// UartDev is defined and initialized in rom code.
extern
UartDevice
UartDev
;
static
bool
uart_getc
(
char
*
c
){
RcvMsgBuff
*
pRxBuff
=
&
(
UartDev
.
rcv_buff
);
if
(
pRxBuff
->
pWritePos
==
pRxBuff
->
pReadPos
){
// empty
return
false
;
}
// ETS_UART_INTR_DISABLE();
ETS_INTR_LOCK
();
*
c
=
(
char
)
*
(
pRxBuff
->
pReadPos
);
if
(
pRxBuff
->
pReadPos
==
(
pRxBuff
->
pRcvMsgBuff
+
RX_BUFF_SIZE
))
{
pRxBuff
->
pReadPos
=
pRxBuff
->
pRcvMsgBuff
;
}
else
{
pRxBuff
->
pReadPos
++
;
}
// ETS_UART_INTR_ENABLE();
ETS_INTR_UNLOCK
();
return
true
;
}
/*
** input_handler at high-priority is a system post task used to process pending Rx
** data on UART0. The flag is used as a latch to stop the interrupt handler posting
** multiple pending requests. At low priority it is used the trigger interactive
** compile.
**
** The ins.data check detects up the first task call which used to initialise
** everything.
*/
int
lua_main
(
void
);
static
bool
input_readline
(
void
);
static
void
input_handler
(
platform_task_param_t
flag
,
uint8
priority
)
{
(
void
)
priority
;
if
(
!
ins
.
data
)
{
lua_main
();
return
;
}
ins
.
input_sig_flag
=
flag
&
0x1
;
while
(
input_readline
())
{}
}
/*
** The input state (ins) is private, so input_setup() exposes the necessary
** access to public properties and is called in user_init() before the Lua
** enviroment is initialised. The second routine input_setup_receive() is
** called in lua.c after the Lua environment is available to bind the Lua
** input handler. Any UART input before this receive setup is ignored.
*/
void
input_setup
(
int
bufsize
,
const
char
*
prompt
)
{
// Initialise non-zero elements
ins
.
run_input
=
true
;
ins
.
uart_echo
=
true
;
ins
.
data
=
os_malloc
(
bufsize
);
ins
.
len
=
bufsize
;
ins
.
prompt
=
prompt
;
ins
.
input_sig
=
platform_task_get_id
(
input_handler
);
// pass the task CB parameters to the uart driver
uart_init_task
(
ins
.
input_sig
,
&
ins
.
input_sig_flag
);
ETS_UART_INTR_ENABLE
();
}
void
input_setup_receive
(
uart_cb_t
uart_on_data_cb
,
int
data_len
,
char
end_char
,
bool
run_input
)
{
ins
.
uart_cb
=
uart_on_data_cb
;
ins
.
data_len
=
data_len
;
ins
.
end_char
=
end_char
;
ins
.
run_input
=
run_input
;
}
void
input_setecho
(
bool
flag
)
{
ins
.
uart_echo
=
flag
;
}
void
input_setprompt
(
const
char
*
prompt
)
{
ins
.
prompt
=
prompt
;
}
/*
** input_readline() is called from the input_handler() event routine which is
** posted by the UART Rx ISR posts. This works in one of two modes depending on
** the bool ins.run_input.
** - TRUE: it clears the UART FIFO up to EOL, doing any callback and sending
** the line to Lua.
** - FALSE: it clears the UART FIFO doing callbacks according to the data_len /
** end_char break.
*/
void
lua_input_string
(
const
char
*
line
,
int
len
);
static
bool
input_readline
(
void
)
{
char
ch
=
NUL
;
if
(
ins
.
run_input
)
{
while
(
uart_getc
(
&
ch
))
{
/* handle CR & LF characters and aggregate \n\r and \r\n pairs */
if
((
ch
==
CR
&&
ins
.
last_char
==
LF
)
||
(
ch
==
LF
&&
ins
.
last_char
==
CR
))
{
ins
.
last_char
=
NUL
;
continue
;
}
/* backspace key */
if
(
ch
==
DEL
||
ch
==
BS
)
{
if
(
ins
.
line_pos
>
0
)
{
if
(
ins
.
uart_echo
)
sendStr
(
BS_OVER
);
ins
.
line_pos
--
;
}
ins
.
data
[
ins
.
line_pos
]
=
0
;
ins
.
last_char
=
NUL
;
continue
;
}
ins
.
last_char
=
ch
;
/* end of data */
if
(
ch
==
CR
||
ch
==
LF
)
{
if
(
ins
.
uart_echo
)
putc
(
LF
);
if
(
ins
.
uart_cb
)
ins
.
uart_cb
(
ins
.
data
,
ins
.
line_pos
);
if
(
ins
.
line_pos
==
0
)
{
/* Get a empty data, then go to get a new data */
sendStr
(
ins
.
prompt
);
continue
;
}
else
{
ins
.
data
[
ins
.
line_pos
++
]
=
LF
;
lua_input_string
(
ins
.
data
,
ins
.
line_pos
);
ins
.
line_pos
=
0
;
return
true
;
}
}
if
(
ins
.
uart_echo
)
putc
(
ch
);
/* it's a large data, discard it */
if
(
ins
.
line_pos
+
1
>=
ins
.
len
){
ins
.
line_pos
=
0
;
}
ins
.
data
[
ins
.
line_pos
++
]
=
ch
;
}
}
else
{
if
(
!
ins
.
uart_cb
)
{
while
(
uart_getc
(
&
ch
))
{}
}
else
if
(
ins
.
data_len
==
0
)
{
while
(
uart_getc
(
&
ch
))
{
ins
.
uart_cb
(
&
ch
,
1
);
}
}
else
{
while
(
uart_getc
(
&
ch
))
{
ins
.
data
[
ins
.
line_pos
++
]
=
ch
;
if
(
ins
.
line_pos
>=
ins
.
len
||
(
ins
.
data_len
>
0
&&
ins
.
line_pos
>=
ins
.
data_len
)
||
ch
==
ins
.
end_char
)
{
ins
.
uart_cb
(
ins
.
data
,
ins
.
line_pos
);
ins
.
line_pos
=
0
;
}
}
}
}
return
false
;
}
app/driver/pwm.c
View file @
e7c29fe3
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
#include "driver/pwm.h"
#include "driver/pwm.h"
// #define PWM_DBG os_printf
// #define PWM_DBG os_printf
#define PWM_DBG
#define PWM_DBG
( ... )
// Enabling the next line will cause the interrupt handler to toggle
// Enabling the next line will cause the interrupt handler to toggle
// this output pin during processing so that the timing is obvious
// this output pin during processing so that the timing is obvious
...
@@ -253,7 +253,7 @@ pwm_set_freq(uint16 freq, uint8 channel)
...
@@ -253,7 +253,7 @@ pwm_set_freq(uint16 freq, uint8 channel)
pwm
.
period
=
PWM_1S
/
pwm
.
freq
;
pwm
.
period
=
PWM_1S
/
pwm
.
freq
;
}
}
#if 0
/******************************************************************************
/******************************************************************************
* FunctionName : pwm_set_freq_duty
* FunctionName : pwm_set_freq_duty
* Description : set pwm frequency and each channel's duty
* Description : set pwm frequency and each channel's duty
...
@@ -274,7 +274,7 @@ pwm_set_freq_duty(uint16 freq, uint16 *duty)
...
@@ -274,7 +274,7 @@ pwm_set_freq_duty(uint16 freq, uint16 *duty)
pwm_set_duty(duty[i], pwm_out_io_num[i]);
pwm_set_duty(duty[i], pwm_out_io_num[i]);
}
}
}
}
#endif
/******************************************************************************
/******************************************************************************
* FunctionName : pwm_get_duty
* FunctionName : pwm_get_duty
* Description : get duty of each channel
* Description : get duty of each channel
...
...
app/driver/readline.c
deleted
100644 → 0
View file @
3d917850
#include "ets_sys.h"
#include "os_type.h"
#include "osapi.h"
#include "driver/uart.h"
#include <stdint.h>
LOCAL
os_timer_t
readline_timer
;
// UartDev is defined and initialized in rom code.
extern
UartDevice
UartDev
;
#define uart_putc uart0_putc
bool
uart_getc
(
char
*
c
){
RcvMsgBuff
*
pRxBuff
=
&
(
UartDev
.
rcv_buff
);
if
(
pRxBuff
->
pWritePos
==
pRxBuff
->
pReadPos
){
// empty
return
false
;
}
// ETS_UART_INTR_DISABLE();
ETS_INTR_LOCK
();
*
c
=
(
char
)
*
(
pRxBuff
->
pReadPos
);
if
(
pRxBuff
->
pReadPos
==
(
pRxBuff
->
pRcvMsgBuff
+
RX_BUFF_SIZE
))
{
pRxBuff
->
pReadPos
=
pRxBuff
->
pRcvMsgBuff
;
}
else
{
pRxBuff
->
pReadPos
++
;
}
// ETS_UART_INTR_ENABLE();
ETS_INTR_UNLOCK
();
return
true
;
}
#if 0
int readline4lua(const char *prompt, char *buffer, int length){
char ch;
int line_position;
start:
/* show prompt */
uart0_sendStr(prompt);
line_position = 0;
os_memset(buffer, 0, length);
while (1)
{
while (uart_getc(&ch))
{
/* handle CR key */
if (ch == '\r')
{
char next;
if (uart_getc(&next))
ch = next;
}
/* backspace key */
else if (ch == 0x7f || ch == 0x08)
{
if (line_position > 0)
{
uart_putc(0x08);
uart_putc(' ');
uart_putc(0x08);
line_position--;
}
buffer[line_position] = 0;
continue;
}
/* EOF(ctrl+d) */
else if (ch == 0x04)
{
if (line_position == 0)
/* No input which makes lua interpreter close */
return 0;
else
continue;
}
/* end of line */
if (ch == '\r' || ch == '\n')
{
buffer[line_position] = 0;
uart_putc('\n');
if (line_position == 0)
{
/* Get a empty line, then go to get a new line */
goto start;
}
else
{
return line_position;
}
}
/* other control character or not an acsii character */
if (ch < 0x20 || ch >= 0x80)
{
continue;
}
/* echo */
uart_putc(ch);
buffer[line_position] = ch;
ch = 0;
line_position++;
/* it's a large line, discard it */
if (line_position >= length)
line_position = 0;
}
}
}
#endif
app/driver/rotary.c
View file @
e7c29fe3
...
@@ -14,9 +14,9 @@
...
@@ -14,9 +14,9 @@
#include <stdint.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
#include "task/task.h"
#include "driver/rotary.h"
#include "driver/rotary.h"
#include "user_interface.h"
#include "user_interface.h"
#include "task/task.h"
#include "ets_sys.h"
#include "ets_sys.h"
//
//
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
#define GET_READ_STATUS(d) (d->queue[d->read_offset & (QUEUE_SIZE - 1)])
#define GET_READ_STATUS(d) (d->queue[d->read_offset & (QUEUE_SIZE - 1)])
#define ADVANCE_IF_POSSIBLE(d) if (d->read_offset < d->write_offset) { d->read_offset++; }
#define ADVANCE_IF_POSSIBLE(d) if (d->read_offset < d->write_offset) { d->read_offset++; }
#define STATUS_IS_PRESSED(x) ((
x
& 0x80000000) != 0)
#define STATUS_IS_PRESSED(x) ((
(x)
& 0x80000000) != 0)
typedef
struct
{
typedef
struct
{
int8_t
phase_a_pin
;
int8_t
phase_a_pin
;
...
@@ -213,7 +213,6 @@ int rotary_setup(uint32_t channel, int phase_a, int phase_b, int press, task_han
...
@@ -213,7 +213,6 @@ int rotary_setup(uint32_t channel, int phase_a, int phase_b, int press, task_han
}
}
data
[
channel
]
=
d
;
data
[
channel
]
=
d
;
int
i
;
d
->
tasknumber
=
tasknumber
;
d
->
tasknumber
=
tasknumber
;
...
...
app/driver/spi.c
View file @
e7c29fe3
...
@@ -15,7 +15,6 @@ static uint32_t spi_clkdiv[2];
...
@@ -15,7 +15,6 @@ static uint32_t spi_clkdiv[2];
*******************************************************************************/
*******************************************************************************/
void
spi_lcd_mode_init
(
uint8
spi_no
)
void
spi_lcd_mode_init
(
uint8
spi_no
)
{
{
uint32
regvalue
;
if
(
spi_no
>
1
)
return
;
//handle invalid input number
if
(
spi_no
>
1
)
return
;
//handle invalid input number
//bit9 of PERIPHS_IO_MUX should be cleared when HSPI clock doesn't equal CPU clock
//bit9 of PERIPHS_IO_MUX should be cleared when HSPI clock doesn't equal CPU clock
//bit8 of PERIPHS_IO_MUX should be cleared when SPI clock doesn't equal CPU clock
//bit8 of PERIPHS_IO_MUX should be cleared when SPI clock doesn't equal CPU clock
...
@@ -112,8 +111,6 @@ uint32_t spi_set_clkdiv(uint8 spi_no, uint32_t clock_div)
...
@@ -112,8 +111,6 @@ uint32_t spi_set_clkdiv(uint8 spi_no, uint32_t clock_div)
*******************************************************************************/
*******************************************************************************/
void
spi_master_init
(
uint8
spi_no
,
unsigned
cpol
,
unsigned
cpha
,
uint32_t
clock_div
)
void
spi_master_init
(
uint8
spi_no
,
unsigned
cpol
,
unsigned
cpha
,
uint32_t
clock_div
)
{
{
uint32
regvalue
;
if
(
spi_no
>
1
)
return
;
//handle invalid input number
if
(
spi_no
>
1
)
return
;
//handle invalid input number
SET_PERI_REG_MASK
(
SPI_USER
(
spi_no
),
SPI_CS_SETUP
|
SPI_CS_HOLD
|
SPI_RD_BYTE_ORDER
|
SPI_WR_BYTE_ORDER
);
SET_PERI_REG_MASK
(
SPI_USER
(
spi_no
),
SPI_CS_SETUP
|
SPI_CS_HOLD
|
SPI_RD_BYTE_ORDER
|
SPI_WR_BYTE_ORDER
);
...
@@ -258,7 +255,7 @@ void spi_mast_set_mosi(uint8 spi_no, uint16 offset, uint8 bitlen, uint32 data)
...
@@ -258,7 +255,7 @@ void spi_mast_set_mosi(uint8 spi_no, uint16 offset, uint8 bitlen, uint32 data)
}
}
shift
=
64
-
(
offset
&
0x1f
)
-
bitlen
;
shift
=
64
-
(
offset
&
0x1f
)
-
bitlen
;
spi_buf
.
dword
&=
~
((
1ULL
<<
bitlen
)
-
1
<<
shift
);
spi_buf
.
dword
&=
~
((
(
1ULL
<<
bitlen
)
-
1
)
<<
shift
);
spi_buf
.
dword
|=
(
uint64
)
data
<<
shift
;
spi_buf
.
dword
|=
(
uint64
)
data
<<
shift
;
if
(
wn
<
15
)
{
if
(
wn
<
15
)
{
...
@@ -344,7 +341,7 @@ void spi_mast_transaction(uint8 spi_no, uint8 cmd_bitlen, uint16 cmd_data, uint8
...
@@ -344,7 +341,7 @@ void spi_mast_transaction(uint8 spi_no, uint8 cmd_bitlen, uint16 cmd_data, uint8
uint16
cmd
=
cmd_data
<<
(
16
-
cmd_bitlen
);
// align to MSB
uint16
cmd
=
cmd_data
<<
(
16
-
cmd_bitlen
);
// align to MSB
cmd
=
(
cmd
>>
8
)
|
(
cmd
<<
8
);
// swap byte order
cmd
=
(
cmd
>>
8
)
|
(
cmd
<<
8
);
// swap byte order
WRITE_PERI_REG
(
SPI_USER2
(
spi_no
),
WRITE_PERI_REG
(
SPI_USER2
(
spi_no
),
((
cmd_bitlen
-
1
&
SPI_USR_COMMAND_BITLEN
)
<<
SPI_USR_COMMAND_BITLEN_S
)
|
((
(
cmd_bitlen
-
1
)
&
SPI_USR_COMMAND_BITLEN
)
<<
SPI_USR_COMMAND_BITLEN_S
)
|
(
cmd
&
SPI_USR_COMMAND_VALUE
));
(
cmd
&
SPI_USR_COMMAND_VALUE
));
SET_PERI_REG_MASK
(
SPI_USER
(
spi_no
),
SPI_USR_COMMAND
);
SET_PERI_REG_MASK
(
SPI_USER
(
spi_no
),
SPI_USR_COMMAND
);
}
}
...
@@ -387,8 +384,6 @@ void spi_mast_transaction(uint8 spi_no, uint8 cmd_bitlen, uint16 cmd_data, uint8
...
@@ -387,8 +384,6 @@ void spi_mast_transaction(uint8 spi_no, uint8 cmd_bitlen, uint16 cmd_data, uint8
*******************************************************************************/
*******************************************************************************/
void
spi_byte_write_espslave
(
uint8
spi_no
,
uint8
data
)
void
spi_byte_write_espslave
(
uint8
spi_no
,
uint8
data
)
{
{
uint32
regvalue
;
if
(
spi_no
>
1
)
return
;
//handle invalid input number
if
(
spi_no
>
1
)
return
;
//handle invalid input number
while
(
READ_PERI_REG
(
SPI_CMD
(
spi_no
))
&
SPI_USR
);
while
(
READ_PERI_REG
(
SPI_CMD
(
spi_no
))
&
SPI_USR
);
...
@@ -413,8 +408,6 @@ void spi_byte_write_espslave(uint8 spi_no,uint8 data)
...
@@ -413,8 +408,6 @@ void spi_byte_write_espslave(uint8 spi_no,uint8 data)
*******************************************************************************/
*******************************************************************************/
void
spi_byte_read_espslave
(
uint8
spi_no
,
uint8
*
data
)
void
spi_byte_read_espslave
(
uint8
spi_no
,
uint8
*
data
)
{
{
uint32
regvalue
;
if
(
spi_no
>
1
)
return
;
//handle invalid input number
if
(
spi_no
>
1
)
return
;
//handle invalid input number
while
(
READ_PERI_REG
(
SPI_CMD
(
spi_no
))
&
SPI_USR
);
while
(
READ_PERI_REG
(
SPI_CMD
(
spi_no
))
&
SPI_USR
);
...
@@ -440,7 +433,7 @@ void spi_byte_write_espslave(uint8 spi_no,uint8 data)
...
@@ -440,7 +433,7 @@ void spi_byte_write_espslave(uint8 spi_no,uint8 data)
*******************************************************************************/
*******************************************************************************/
void
spi_slave_init
(
uint8
spi_no
)
void
spi_slave_init
(
uint8
spi_no
)
{
{
uint32
regvalue
;
//
uint32 regvalue;
if
(
spi_no
>
1
)
if
(
spi_no
>
1
)
return
;
//handle invalid input number
return
;
//handle invalid input number
...
@@ -565,7 +558,6 @@ void hspi_master_readwrite_repeat(void)
...
@@ -565,7 +558,6 @@ void hspi_master_readwrite_repeat(void)
#include "mem.h"
#include "mem.h"
static
uint8
spi_data
[
32
]
=
{
0
};
static
uint8
spi_data
[
32
]
=
{
0
};
static
uint8
idx
=
0
;
static
uint8
idx
=
0
;
static
uint8
spi_flg
=
0
;
#define SPI_MISO
#define SPI_MISO
#define SPI_QUEUE_LEN 8
#define SPI_QUEUE_LEN 8
os_event_t
*
spiQueue
;
os_event_t
*
spiQueue
;
...
@@ -596,9 +588,8 @@ void ICACHE_FLASH_ATTR
...
@@ -596,9 +588,8 @@ void ICACHE_FLASH_ATTR
void
spi_slave_isr_handler
(
void
*
para
)
void
spi_slave_isr_handler
(
void
*
para
)
{
{
uint32
regvalue
,
calvalue
;
uint32
regvalue
;
static
uint8
state
=
0
;
uint32
recv_data
;
uint32
recv_data
,
send_data
;
if
(
READ_PERI_REG
(
0x3ff00020
)
&
BIT4
){
if
(
READ_PERI_REG
(
0x3ff00020
)
&
BIT4
){
//following 3 lines is to clear isr signal
//following 3 lines is to clear isr signal
...
...
app/driver/switec.c
View file @
e7c29fe3
...
@@ -18,13 +18,13 @@
...
@@ -18,13 +18,13 @@
#include <stddef.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
#include "task/task.h"
#include "driver/switec.h"
#include "driver/switec.h"
#include "ets_sys.h"
#include "ets_sys.h"
#include "os_type.h"
#include "os_type.h"
#include "osapi.h"
#include "osapi.h"
#include "hw_timer.h"
#include "hw_timer.h"
#include "user_interface.h"
#include "user_interface.h"
#include "task/task.h"
#define N_STATES 6
#define N_STATES 6
//
//
...
...
app/driver/uart.c
View file @
e7c29fe3
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
#include "ets_sys.h"
#include "ets_sys.h"
#include "osapi.h"
#include "osapi.h"
#include "driver/uart.h"
#include "driver/uart.h"
#include "
task/task
.h"
#include "
platform
.h"
#include "user_config.h"
#include "user_config.h"
#include "user_interface.h"
#include "user_interface.h"
#include "osapi.h"
#include "osapi.h"
...
@@ -29,15 +29,15 @@
...
@@ -29,15 +29,15 @@
// For event signalling
// For event signalling
static
task_handle_t
sig
=
0
;
static
platform_
task_handle_t
sig
=
0
;
static
uint8
*
sig_flag
;
static
uint8
*
sig_flag
;
static
uint8
isr_flag
=
0
;
static
uint8
isr_flag
=
0
;
// UartDev is defined and initialized in rom code.
// UartDev is defined and initialized in rom code.
extern
UartDevice
UartDev
;
extern
UartDevice
UartDev
;
#ifdef BIT_RATE_AUTOBAUD
static
os_timer_t
autobaud_timer
;
static
os_timer_t
autobaud_timer
;
#endif
static
void
(
*
alt_uart0_tx
)(
char
txchar
);
static
void
(
*
alt_uart0_tx
)(
char
txchar
);
LOCAL
void
ICACHE_RAM_ATTR
LOCAL
void
ICACHE_RAM_ATTR
...
@@ -165,7 +165,7 @@ uart_tx_one_char(uint8 uart, uint8 TxChar)
...
@@ -165,7 +165,7 @@ uart_tx_one_char(uint8 uart, uint8 TxChar)
WRITE_PERI_REG
(
UART_FIFO
(
uart
)
,
TxChar
);
WRITE_PERI_REG
(
UART_FIFO
(
uart
)
,
TxChar
);
return
OK
;
return
OK
;
}
}
#if 0
/******************************************************************************
/******************************************************************************
* FunctionName : uart1_write_char
* FunctionName : uart1_write_char
* Description : Internal used function
* Description : Internal used function
...
@@ -189,7 +189,7 @@ uart1_write_char(char c)
...
@@ -189,7 +189,7 @@ uart1_write_char(char c)
uart_tx_one_char(UART1, c);
uart_tx_one_char(UART1, c);
}
}
}
}
#endif
/******************************************************************************
/******************************************************************************
* FunctionName : uart0_tx_buffer
* FunctionName : uart0_tx_buffer
* Description : use uart0 to transfer buffer
* Description : use uart0 to transfer buffer
...
@@ -300,13 +300,15 @@ uart0_rx_intr_handler(void *para)
...
@@ -300,13 +300,15 @@ uart0_rx_intr_handler(void *para)
}
}
if
(
got_input
&&
sig
)
{
if
(
got_input
&&
sig
)
{
// Only post a new handler request once the handler has fired clearing the last post
if
(
isr_flag
==
*
sig_flag
)
{
if
(
isr_flag
==
*
sig_flag
)
{
isr_flag
^=
0x01
;
isr_flag
^=
0x01
;
task
_post_
low
(
sig
,
0x8000
|
isr_flag
<<
14
|
false
);
platform
_post_
high
(
sig
,
isr_flag
);
}
}
}
}
}
}
#ifdef BIT_RATE_AUTOBAUD
static
void
static
void
uart_autobaud_timeout
(
void
*
timer_arg
)
uart_autobaud_timeout
(
void
*
timer_arg
)
{
{
...
@@ -324,7 +326,6 @@ uart_autobaud_timeout(void *timer_arg)
...
@@ -324,7 +326,6 @@ uart_autobaud_timeout(void *timer_arg)
}
}
}
}
#include "pm/swtimer.h"
#include "pm/swtimer.h"
static
void
static
void
uart_init_autobaud
(
uint32_t
uart_no
)
uart_init_autobaud
(
uint32_t
uart_no
)
{
{
...
@@ -339,22 +340,17 @@ uart_stop_autobaud()
...
@@ -339,22 +340,17 @@ uart_stop_autobaud()
{
{
os_timer_disarm
(
&
autobaud_timer
);
os_timer_disarm
(
&
autobaud_timer
);
}
}
#endif
/******************************************************************************
/******************************************************************************
* FunctionName : uart_init
* FunctionName : uart_init
* Description : user interface for init uart
* Description : user interface for init uart
* Parameters : UartBautRate uart0_br - uart0 bautrate
* Parameters : UartBautRate uart0_br - uart0 bautrate
* UartBautRate uart1_br - uart1 bautrate
* UartBautRate uart1_br - uart1 bautrate
* os_signal_t sig_input - signal to post
* uint8 *flag_input - flag of consumer task
* Returns : NONE
* Returns : NONE
*******************************************************************************/
*******************************************************************************/
void
ICACHE_FLASH_ATTR
void
ICACHE_FLASH_ATTR
uart_init
(
UartBautRate
uart0_br
,
UartBautRate
uart1_br
,
os_signal_t
sig_input
,
uint8
*
flag_input
)
uart_init
(
UartBautRate
uart0_br
,
UartBautRate
uart1_br
)
{
{
sig
=
sig_input
;
sig_flag
=
flag_input
;
// rom use 74880 baut_rate, here reinitialize
// rom use 74880 baut_rate, here reinitialize
UartDev
.
baut_rate
=
uart0_br
;
UartDev
.
baut_rate
=
uart0_br
;
uart_config
(
UART0
);
uart_config
(
UART0
);
...
@@ -378,6 +374,19 @@ uart_setup(uint8 uart_no)
...
@@ -378,6 +374,19 @@ uart_setup(uint8 uart_no)
ETS_UART_INTR_ENABLE
();
ETS_UART_INTR_ENABLE
();
}
}
/******************************************************************************
* FunctionName : uart_init_task
* Description : user interface for init uart task callback
* Parameters : os_signal_t sig_input - signal to post
* uint8 *flag_input - flag of consumer task
* Returns : NONE
*******************************************************************************/
void
ICACHE_FLASH_ATTR
uart_init_task
(
os_signal_t
sig_input
,
uint8
*
flag_input
)
{
sig
=
sig_input
;
sig_flag
=
flag_input
;
}
void
ICACHE_FLASH_ATTR
uart_set_alt_output_uart0
(
void
(
*
fn
)(
char
))
{
void
ICACHE_FLASH_ATTR
uart_set_alt_output_uart0
(
void
(
*
fn
)(
char
))
{
alt_uart0_tx
=
fn
;
alt_uart0_tx
=
fn
;
}
}
...
...
app/include/driver/input.h
0 → 100644
View file @
e7c29fe3
#ifndef READLINE_APP_H
#define READLINE_APP_H
typedef
void
(
*
uart_cb_t
)(
const
char
*
buf
,
size_t
len
);
extern
void
input_setup
(
int
bufsize
,
const
char
*
prompt
);
extern
void
input_setup_receive
(
uart_cb_t
uart_on_data_cb
,
int
data_len
,
char
end_char
,
bool
run_input
);
extern
void
input_setecho
(
bool
flag
);
extern
void
input_setprompt
(
const
char
*
prompt
);
extern
void
input_process_arm
(
void
);
#endif
/* READLINE_APP_H */
app/include/driver/readline.h
deleted
100644 → 0
View file @
3d917850
#ifndef READLINE_APP_H
#define READLINE_APP_H
bool
uart_getc
(
char
*
c
);
#endif
/* READLINE_APP_H */
app/include/driver/uart.h
View file @
e7c29fe3
...
@@ -110,7 +110,8 @@ typedef struct {
...
@@ -110,7 +110,8 @@ typedef struct {
UartStopBitsNum
stop_bits
;
UartStopBitsNum
stop_bits
;
}
UartConfig
;
}
UartConfig
;
void
uart_init
(
UartBautRate
uart0_br
,
UartBautRate
uart1_br
,
os_signal_t
sig_input
,
uint8
*
flag_input
);
void
uart_init
(
UartBautRate
uart0_br
,
UartBautRate
uart1_br
);
void
uart_init_task
(
os_signal_t
sig_input
,
uint8
*
flag_input
);
UartConfig
uart_get_config
(
uint8
uart_no
);
UartConfig
uart_get_config
(
uint8
uart_no
);
void
uart0_alt
(
uint8
on
);
void
uart0_alt
(
uint8
on
);
void
uart0_sendStr
(
const
char
*
str
);
void
uart0_sendStr
(
const
char
*
str
);
...
...
app/include/task/task.h
View file @
e7c29fe3
#ifndef _TASK_H_
#ifndef _TASK_H_
#define _TASK_H_
#define _TASK_H_
#include "ets_sys.h"
#include "osapi.h"
#include "os_type.h"
#include "user_interface.h"
/* use LOW / MEDIUM / HIGH since it isn't clear from the docs which is higher */
#define TASK_PRIORITY_LOW 0
#define TASK_PRIORITY_MEDIUM 1
#define TASK_PRIORITY_HIGH 2
#define TASK_PRIORITY_COUNT 3
/*
/*
* Signals are a 32-bit number of the form header:14; count:16, priority:2. The header
** The task interface is now part of the core platform interface.
* is just a fixed fingerprint and the count is allocated serially by the task get_id()
** This header is preserved for backwards compatability only.
* function.
*/
*/
#define task_post(priority,handle,param) system_os_post(priority, ((handle) | priority), param)
#include "platform.h"
#define task_post_low(handle,param) task_post(TASK_PRIORITY_LOW, handle, param)
#define task_post_medium(handle,param) task_post(TASK_PRIORITY_MEDIUM, handle, param)
#define task_post_high(handle,param) task_post(TASK_PRIORITY_HIGH, handle, param)
#define task_handle_t os_signal_t
#define TASK_PRIORITY_LOW PLATFORM_TASK_PRIORITY_LOW
#define task_param_t os_param_t
#define TASK_PRIORITY_MEDIUM PLATFORM_TASK_PRIORITY_MEDIUM
#define TASK_PRIORITY_HIGH PLATFORM_TASK_PRIORITY_HIGH
typedef
void
(
*
task_callback_t
)(
task_param_t
param
,
uint8
prio
);
#define task_post(priority,handle,param) platform_post(priority,handle,param)
#define task_post_low(handle,param) platform_post_low(handle,param)
#define task_post_medium(handle,param) platform_post_medium(handle,param)
#define task_post_high(handle,param) platform_post_high(handle,param)
bool
task_init_handler
(
uint8
priority
,
uint8
qlen
);
#define task_handle_t platform_task_handle_t
task_handle_t
task_get_id
(
task_callback_t
t
);
#define task_param_t platform_task_param_t
#define task_callback_t platform_task_callback_t
#define task_get_id platform_task_get_id
#endif
#endif
app/include/user_config.h
View file @
e7c29fe3
...
@@ -263,14 +263,14 @@ extern void dbg_printf(const char *fmt, ...);
...
@@ -263,14 +263,14 @@ extern void dbg_printf(const char *fmt, ...);
#ifdef NODE_DEBUG
#ifdef NODE_DEBUG
#define NODE_DBG dbg_printf
#define NODE_DBG dbg_printf
#else
#else
#define NODE_DBG
#define NODE_DBG
( ... )
#endif
/* NODE_DEBUG */
#endif
/* NODE_DEBUG */
#define NODE_ERROR
#define NODE_ERROR
#ifdef NODE_ERROR
#ifdef NODE_ERROR
#define NODE_ERR dbg_printf
#define NODE_ERR dbg_printf
#else
#else
#define NODE_ERR
#define NODE_ERR
( ... )
#endif
/* NODE_ERROR */
#endif
/* NODE_ERROR */
// #define GPIO_SAFE_NO_INTR_ENABLE
// #define GPIO_SAFE_NO_INTR_ENABLE
...
...
app/lua/Makefile
View file @
e7c29fe3
...
@@ -16,7 +16,7 @@ SUBDIRS = luac_cross
...
@@ -16,7 +16,7 @@ SUBDIRS = luac_cross
GEN_LIBS
=
liblua.a
GEN_LIBS
=
liblua.a
endif
endif
STD_CFLAGS
=
-std
=
gnu11
-Wimplicit
STD_CFLAGS
=
-std
=
gnu11
-Wimplicit
-Wall
#############################################################
#############################################################
# Configuration i.e. compile options etc.
# Configuration i.e. compile options etc.
...
...
app/lua/lauxlib.c
View file @
e7c29fe3
...
@@ -824,10 +824,9 @@ static int errfsfile (lua_State *L, const char *what, int fnameindex) {
...
@@ -824,10 +824,9 @@ static int errfsfile (lua_State *L, const char *what, int fnameindex) {
}
}
LUALIB_API
int
luaL_loadf
sf
ile
(
lua_State
*
L
,
const
char
*
filename
)
{
LUALIB_API
int
luaL_loadfile
(
lua_State
*
L
,
const
char
*
filename
)
{
LoadFSF
lf
;
LoadFSF
lf
;
int
status
,
readstatus
;
int
status
,
c
;
int
c
;
int
fnameindex
=
lua_gettop
(
L
)
+
1
;
/* index of filename on the stack */
int
fnameindex
=
lua_gettop
(
L
)
+
1
;
/* index of filename on the stack */
lf
.
extraline
=
0
;
lf
.
extraline
=
0
;
if
(
filename
==
NULL
)
{
if
(
filename
==
NULL
)
{
...
...
app/lua/lauxlib.h
View file @
e7c29fe3
...
@@ -79,7 +79,7 @@ LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
...
@@ -79,7 +79,7 @@ LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
#ifdef LUA_CROSS_COMPILER
#ifdef LUA_CROSS_COMPILER
LUALIB_API
int
(
luaL_loadfile
)
(
lua_State
*
L
,
const
char
*
filename
);
LUALIB_API
int
(
luaL_loadfile
)
(
lua_State
*
L
,
const
char
*
filename
);
#else
#else
LUALIB_API
int
(
luaL_loadf
sf
ile
)
(
lua_State
*
L
,
const
char
*
filename
);
LUALIB_API
int
(
luaL_loadfile
)
(
lua_State
*
L
,
const
char
*
filename
);
#endif
#endif
LUALIB_API
int
(
luaL_loadbuffer
)
(
lua_State
*
L
,
const
char
*
buff
,
size_t
sz
,
LUALIB_API
int
(
luaL_loadbuffer
)
(
lua_State
*
L
,
const
char
*
buff
,
size_t
sz
,
const
char
*
name
);
const
char
*
name
);
...
@@ -119,7 +119,7 @@ LUALIB_API void luaL_assertfail(const char *file, int line, const char *message)
...
@@ -119,7 +119,7 @@ LUALIB_API void luaL_assertfail(const char *file, int line, const char *message)
(luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
(luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
#else
#else
#define luaL_dofile(L, fn) \
#define luaL_dofile(L, fn) \
(luaL_loadf
sf
ile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
(luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
#endif
#endif
#define luaL_dostring(L, s) \
#define luaL_dostring(L, s) \
...
...
app/lua/lbaselib.c
View file @
e7c29fe3
...
@@ -19,8 +19,6 @@
...
@@ -19,8 +19,6 @@
#include "lrotable.h"
#include "lrotable.h"
/*
/*
** If your system does not support `stdout', you can just remove this function.
** If your system does not support `stdout', you can just remove this function.
** If you need, you can define your own `print' function, following this
** If you need, you can define your own `print' function, following this
...
@@ -40,20 +38,11 @@ static int luaB_print (lua_State *L) {
...
@@ -40,20 +38,11 @@ static int luaB_print (lua_State *L) {
if
(
s
==
NULL
)
if
(
s
==
NULL
)
return
luaL_error
(
L
,
LUA_QL
(
"tostring"
)
" must return a string to "
return
luaL_error
(
L
,
LUA_QL
(
"tostring"
)
" must return a string to "
LUA_QL
(
"print"
));
LUA_QL
(
"print"
));
#if defined(LUA_USE_STDIO)
if
(
i
>
1
)
puts
(
"
\t
"
);
if
(
i
>
1
)
fputs
(
"
\t
"
,
c_stdout
);
puts
(
s
);
fputs
(
s
,
c_stdout
);
#else
if
(
i
>
1
)
luai_writestring
(
"
\t
"
,
1
);
luai_writestring
(
s
,
strlen
(
s
));
#endif
lua_pop
(
L
,
1
);
/* pop result */
lua_pop
(
L
,
1
);
/* pop result */
}
}
#if defined(LUA_USE_STDIO)
puts
(
"
\n
"
);
fputs
(
"
\n
"
,
c_stdout
);
#else
luai_writeline
();
#endif
return
0
;
return
0
;
}
}
...
@@ -296,7 +285,7 @@ static int luaB_loadfile (lua_State *L) {
...
@@ -296,7 +285,7 @@ static int luaB_loadfile (lua_State *L) {
#ifdef LUA_CROSS_COMPILER
#ifdef LUA_CROSS_COMPILER
return
load_aux
(
L
,
luaL_loadfile
(
L
,
fname
));
return
load_aux
(
L
,
luaL_loadfile
(
L
,
fname
));
#else
#else
return
load_aux
(
L
,
luaL_loadf
sf
ile
(
L
,
fname
));
return
load_aux
(
L
,
luaL_loadfile
(
L
,
fname
));
#endif
#endif
}
}
...
@@ -343,7 +332,7 @@ static int luaB_dofile (lua_State *L) {
...
@@ -343,7 +332,7 @@ static int luaB_dofile (lua_State *L) {
#ifdef LUA_CROSS_COMPILER
#ifdef LUA_CROSS_COMPILER
if
(
luaL_loadfile
(
L
,
fname
)
!=
0
)
lua_error
(
L
);
if
(
luaL_loadfile
(
L
,
fname
)
!=
0
)
lua_error
(
L
);
#else
#else
if
(
luaL_loadf
sf
ile
(
L
,
fname
)
!=
0
)
lua_error
(
L
);
if
(
luaL_loadfile
(
L
,
fname
)
!=
0
)
lua_error
(
L
);
#endif
#endif
lua_call
(
L
,
0
,
LUA_MULTRET
);
lua_call
(
L
,
0
,
LUA_MULTRET
);
return
lua_gettop
(
L
)
-
n
;
return
lua_gettop
(
L
)
-
n
;
...
...
app/lua/ldblib.c
View file @
e7c29fe3
...
@@ -365,7 +365,7 @@ static int db_debug (lua_State *L) {
...
@@ -365,7 +365,7 @@ static int db_debug (lua_State *L) {
#define LEVELS1 12
/* size of the first part of the stack */
#define LEVELS1 12
/* size of the first part of the stack */
#define LEVELS2 10
/* size of the second part of the stack */
#define LEVELS2 10
/* size of the second part of the stack */
static
int
d
b
_errorfb
(
lua_State
*
L
)
{
int
d
ebug
_errorfb
(
lua_State
*
L
)
{
int
level
;
int
level
;
int
firstpart
=
1
;
/* still before eventual `...' */
int
firstpart
=
1
;
/* still before eventual `...' */
int
arg
;
int
arg
;
...
@@ -436,7 +436,7 @@ LROT_PUBLIC_BEGIN(dblib)
...
@@ -436,7 +436,7 @@ LROT_PUBLIC_BEGIN(dblib)
LROT_FUNCENTRY
(
setmetatable
,
db_setmetatable
)
LROT_FUNCENTRY
(
setmetatable
,
db_setmetatable
)
LROT_FUNCENTRY
(
setupvalue
,
db_setupvalue
)
LROT_FUNCENTRY
(
setupvalue
,
db_setupvalue
)
#endif
#endif
LROT_FUNCENTRY
(
traceback
,
d
b
_errorfb
)
LROT_FUNCENTRY
(
traceback
,
d
ebug
_errorfb
)
LROT_END
(
dblib
,
NULL
,
0
)
LROT_END
(
dblib
,
NULL
,
0
)
LUALIB_API
int
luaopen_debug
(
lua_State
*
L
)
{
LUALIB_API
int
luaopen_debug
(
lua_State
*
L
)
{
...
...
Prev
1
2
3
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