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
46671928
Commit
46671928
authored
Nov 13, 2018
by
Arnim Läuger
Committed by
Marcel Stör
Nov 13, 2018
Browse files
establish delay as event to trigger flushing of spi buffer (#2517)
parent
1c6894eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/platform/u8x8_nodemcu_hal.c
View file @
46671928
...
...
@@ -13,6 +13,42 @@
#define U8X8_USE_PINS
#include "u8x8_nodemcu_hal.h"
// static variables containing info about the i2c link
// TODO: move to user space in u8x8_t once available
typedef
struct
{
uint8_t
id
;
}
hal_i2c_t
;
// static variables containing info about the spi link
// TODO: move to user space in u8x8_t once available
typedef
struct
{
uint8_t
host
;
//spi_device_handle_t device;
uint8_t
last_dc
;
struct
{
uint8_t
*
data
;
size_t
size
,
used
;
}
buffer
;
}
hal_spi_t
;
static
void
flush_buffer_spi
(
hal_spi_t
*
hal
)
{
if
(
hal
->
buffer
.
data
&&
hal
->
buffer
.
used
>
0
)
{
platform_spi_blkwrite
(
hal
->
host
,
hal
->
buffer
.
used
,
hal
->
buffer
.
data
);
hal
->
buffer
.
used
=
0
;
}
}
static
void
force_flush_buffer
(
u8x8_t
*
u8x8
)
{
// spi hal has a buffer that can be flushed
if
(
u8x8
->
byte_cb
==
u8x8_byte_nodemcu_spi
)
{
hal_spi_t
*
hal
=
((
u8g2_nodemcu_t
*
)
u8x8
)
->
hal
;
flush_buffer_spi
(
hal
);
}
}
uint8_t
u8x8_gpio_and_delay_nodemcu
(
u8x8_t
*
u8x8
,
uint8_t
msg
,
uint8_t
arg_int
,
void
*
arg_ptr
)
{
...
...
@@ -35,25 +71,30 @@ uint8_t u8x8_gpio_and_delay_nodemcu(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int,
break
;
case
U8X8_MSG_DELAY_NANO
:
// delay arg_int * 1 nano second
force_flush_buffer
(
u8x8
);
os_delay_us
(
1
);
break
;
case
U8X8_MSG_DELAY_100NANO
:
// delay arg_int * 100 nano seconds
force_flush_buffer
(
u8x8
);
temp
=
arg_int
*
100
;
temp
/=
1000
;
os_delay_us
(
temp
>
0
?
temp
:
1
);
break
;
case
U8X8_MSG_DELAY_10MICRO
:
// delay arg_int * 10 micro seconds
force_flush_buffer
(
u8x8
);
os_delay_us
(
arg_int
*
10
);
break
;
case
U8X8_MSG_DELAY_MILLI
:
// delay arg_int * 1 milli second
force_flush_buffer
(
u8x8
);
os_delay_us
(
arg_int
*
1000
);
system_soft_wdt_feed
();
break
;
case
U8X8_MSG_DELAY_I2C
:
// arg_int is the I2C speed in 100KHz, e.g. 4 = 400 KHz
force_flush_buffer
(
u8x8
);
temp
=
5000
/
arg_int
;
// arg_int=1: delay by 5us, arg_int = 4: delay by 1.25us
temp
/=
1000
;
os_delay_us
(
temp
>
0
?
temp
:
1
);
...
...
@@ -120,12 +161,6 @@ uint8_t u8x8_gpio_and_delay_nodemcu(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int,
}
// static variables containing info about the i2c link
// TODO: move to user space in u8x8_t once available
typedef
struct
{
uint8_t
id
;
}
hal_i2c_t
;
uint8_t
u8x8_byte_nodemcu_i2c
(
u8x8_t
*
u8x8
,
uint8_t
msg
,
uint8_t
arg_int
,
void
*
arg_ptr
)
{
uint8_t
*
data
;
...
...
@@ -192,27 +227,6 @@ uint8_t u8x8_byte_nodemcu_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *
}
// static variables containing info about the spi link
// TODO: move to user space in u8x8_t once available
typedef
struct
{
uint8_t
host
;
//spi_device_handle_t device;
uint8_t
last_dc
;
struct
{
uint8_t
*
data
;
size_t
size
,
used
;
}
buffer
;
}
hal_spi_t
;
static
void
flush_buffer_spi
(
hal_spi_t
*
hal
)
{
if
(
hal
->
buffer
.
used
>
0
)
{
platform_spi_blkwrite
(
hal
->
host
,
hal
->
buffer
.
used
,
hal
->
buffer
.
data
);
hal
->
buffer
.
used
=
0
;
}
}
uint8_t
u8x8_byte_nodemcu_spi
(
u8x8_t
*
u8x8
,
uint8_t
msg
,
uint8_t
arg_int
,
void
*
arg_ptr
)
{
hal_spi_t
*
hal
=
((
u8g2_nodemcu_t
*
)
u8x8
)
->
hal
;
...
...
@@ -229,6 +243,7 @@ uint8_t u8x8_byte_nodemcu_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *
return
0
;
hal
->
host
=
host
;
((
u8g2_nodemcu_t
*
)
u8x8
)
->
hal
=
hal
;
hal
->
buffer
.
data
=
NULL
;
hal
->
last_dc
=
0
;
}
...
...
@@ -280,6 +295,7 @@ uint8_t u8x8_byte_nodemcu_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *
u8x8_gpio_SetCS
(
u8x8
,
u8x8
->
display_info
->
chip_disable_level
);
c_free
(
hal
->
buffer
.
data
);
hal
->
buffer
.
data
=
NULL
;
break
;
default:
...
...
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