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
6c0adbf9
Commit
6c0adbf9
authored
Feb 20, 2015
by
devsaurus
Browse files
SPI comm function, untested
parent
81be529d
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/modules/u8g.c
View file @
6c0adbf9
...
@@ -826,6 +826,83 @@ static uint8_t u8g_com_esp8266_ssd_start_sequence(u8g_t *u8g)
...
@@ -826,6 +826,83 @@ static uint8_t u8g_com_esp8266_ssd_start_sequence(u8g_t *u8g)
}
}
static
void
lu8g_digital_write
(
u8g_t
*
u8g
,
uint8_t
pin_index
,
uint8_t
value
)
{
uint8_t
pin
;
pin
=
u8g
->
pin_list
[
pin_index
];
if
(
pin
!=
U8G_PIN_NONE
)
platform_gpio_write
(
pin
,
value
);
}
uint8_t
u8g_com_esp8266_hw_spi_fn
(
u8g_t
*
u8g
,
uint8_t
msg
,
uint8_t
arg_val
,
void
*
arg_ptr
)
{
switch
(
msg
)
{
case
U8G_COM_MSG_STOP
:
break
;
case
U8G_COM_MSG_INIT
:
// we assume that the SPI interface was already initialized
// just care for the /CS and D/C pins
lu8g_digital_write
(
u8g
,
U8G_PI_CS
,
PLATFORM_GPIO_HIGH
);
platform_gpio_mode
(
u8g
->
pin_list
[
U8G_PI_CS
],
PLATFORM_GPIO_OUTPUT
,
PLATFORM_GPIO_FLOAT
);
platform_gpio_mode
(
u8g
->
pin_list
[
U8G_PI_A0
],
PLATFORM_GPIO_OUTPUT
,
PLATFORM_GPIO_FLOAT
);
break
;
case
U8G_COM_MSG_ADDRESS
:
/* define cmd (arg_val = 0) or data mode (arg_val = 1) */
lu8g_digital_write
(
u8g
,
U8G_PI_A0
,
arg_val
==
0
?
PLATFORM_GPIO_LOW
:
PLATFORM_GPIO_HIGH
);
break
;
case
U8G_COM_MSG_CHIP_SELECT
:
if
(
arg_val
==
0
)
{
/* disable */
lu8g_digital_write
(
u8g
,
U8G_PI_CS
,
PLATFORM_GPIO_HIGH
);
}
else
{
/* enable */
//u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, LOW);
lu8g_digital_write
(
u8g
,
U8G_PI_CS
,
PLATFORM_GPIO_LOW
);
}
break
;
case
U8G_COM_MSG_RESET
:
if
(
u8g
->
pin_list
[
U8G_PI_RESET
]
!=
U8G_PIN_NONE
)
lu8g_digital_write
(
u8g
,
U8G_PI_RESET
,
arg_val
==
0
?
PLATFORM_GPIO_LOW
:
PLATFORM_GPIO_HIGH
);
break
;
case
U8G_COM_MSG_WRITE_BYTE
:
platform_spi_send_recv
(
1
,
arg_val
);
break
;
case
U8G_COM_MSG_WRITE_SEQ
:
{
register
uint8_t
*
ptr
=
arg_ptr
;
while
(
arg_val
>
0
)
{
platform_spi_send_recv
(
1
,
*
ptr
++
);
arg_val
--
;
}
}
break
;
case
U8G_COM_MSG_WRITE_SEQ_P
:
{
register
uint8_t
*
ptr
=
arg_ptr
;
while
(
arg_val
>
0
)
{
platform_spi_send_recv
(
1
,
u8g_pgm_read
(
ptr
)
);
ptr
++
;
arg_val
--
;
}
}
break
;
}
return
1
;
}
uint8_t
u8g_com_esp8266_ssd_i2c_fn
(
u8g_t
*
u8g
,
uint8_t
msg
,
uint8_t
arg_val
,
void
*
arg_ptr
)
uint8_t
u8g_com_esp8266_ssd_i2c_fn
(
u8g_t
*
u8g
,
uint8_t
msg
,
uint8_t
arg_val
,
void
*
arg_ptr
)
{
{
switch
(
msg
)
switch
(
msg
)
...
@@ -915,7 +992,6 @@ uint8_t u8g_com_esp8266_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, voi
...
@@ -915,7 +992,6 @@ uint8_t u8g_com_esp8266_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, voi
// device destructor
// device destructor
static
int
lu8g_close_display
(
lua_State
*
L
)
static
int
lu8g_close_display
(
lua_State
*
L
)
{
{
...
@@ -955,7 +1031,7 @@ static int lu8g_ssd1306_128x64_i2c( lua_State *L )
...
@@ -955,7 +1031,7 @@ static int lu8g_ssd1306_128x64_i2c( lua_State *L )
// build device entry
// build device entry
lud
->
dev
.
dev_fn
=
u8g_dev_ssd1306_128x64_fn
;
lud
->
dev
.
dev_fn
=
u8g_dev_ssd1306_128x64_fn
;
lud
->
dev
.
dev_mem
=
&
(
lud
->
pb
);
lud
->
dev
.
dev_mem
=
&
(
lud
->
pb
);
lud
->
dev
.
com_fn
=
u8g_com_esp8266_ssd_i2c_fn
;
lud
->
dev
.
com_fn
=
U8G_COM_SSD_I2C
;
// then allocate and populate page buffer
// then allocate and populate page buffer
lud
->
pb
.
width
=
128
;
// WIDTH in u8g_dev_ssd1306_128x64.c
lud
->
pb
.
width
=
128
;
// WIDTH in u8g_dev_ssd1306_128x64.c
if
((
lud
->
pb
.
buf
=
(
void
*
)
c_zalloc
(
lud
->
pb
.
width
))
==
NULL
)
if
((
lud
->
pb
.
buf
=
(
void
*
)
c_zalloc
(
lud
->
pb
.
width
))
==
NULL
)
...
...
app/u8glib/u8g.h
View file @
6c0adbf9
...
@@ -654,6 +654,7 @@ uint8_t u8g_com_arduino_port_d_wr_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, v
...
@@ -654,6 +654,7 @@ uint8_t u8g_com_arduino_port_d_wr_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, v
uint8_t
u8g_com_arduino_no_en_parallel_fn
(
u8g_t
*
u8g
,
uint8_t
msg
,
uint8_t
arg_val
,
void
*
arg_ptr
);
/* u8g_com_arduino_no_en_parallel.c */
uint8_t
u8g_com_arduino_no_en_parallel_fn
(
u8g_t
*
u8g
,
uint8_t
msg
,
uint8_t
arg_val
,
void
*
arg_ptr
);
/* u8g_com_arduino_no_en_parallel.c */
uint8_t
u8g_com_arduino_ssd_i2c_fn
(
u8g_t
*
u8g
,
uint8_t
msg
,
uint8_t
arg_val
,
void
*
arg_ptr
);
/* u8g_com_arduino_ssd_i2c.c */
uint8_t
u8g_com_arduino_ssd_i2c_fn
(
u8g_t
*
u8g
,
uint8_t
msg
,
uint8_t
arg_val
,
void
*
arg_ptr
);
/* u8g_com_arduino_ssd_i2c.c */
uint8_t
u8g_com_esp8266_ssd_i2c_fn
(
u8g_t
*
u8g
,
uint8_t
msg
,
uint8_t
arg_val
,
void
*
arg_ptr
);
/* u8g.c */
uint8_t
u8g_com_esp8266_ssd_i2c_fn
(
u8g_t
*
u8g
,
uint8_t
msg
,
uint8_t
arg_val
,
void
*
arg_ptr
);
/* u8g.c */
uint8_t
u8g_com_esp8266_hw_spi_fn
(
u8g_t
*
u8g
,
uint8_t
msg
,
uint8_t
arg_val
,
void
*
arg_ptr
);
/* u8g.c */
uint8_t
u8g_com_arduino_uc_i2c_fn
(
u8g_t
*
u8g
,
uint8_t
msg
,
uint8_t
arg_val
,
void
*
arg_ptr
);
uint8_t
u8g_com_arduino_uc_i2c_fn
(
u8g_t
*
u8g
,
uint8_t
msg
,
uint8_t
arg_val
,
void
*
arg_ptr
);
uint8_t
u8g_com_arduino_t6963_fn
(
u8g_t
*
u8g
,
uint8_t
msg
,
uint8_t
arg_val
,
void
*
arg_ptr
);
/* u8g_com_arduino_t6963.c */
uint8_t
u8g_com_arduino_t6963_fn
(
u8g_t
*
u8g
,
uint8_t
msg
,
uint8_t
arg_val
,
void
*
arg_ptr
);
/* u8g_com_arduino_t6963.c */
...
@@ -723,6 +724,10 @@ defined(__18CXX) || defined(__PIC32MX)
...
@@ -723,6 +724,10 @@ defined(__18CXX) || defined(__PIC32MX)
#define U8G_COM_HW_SPI u8g_com_atmega_hw_spi_fn
#define U8G_COM_HW_SPI u8g_com_atmega_hw_spi_fn
#define U8G_COM_ST7920_HW_SPI u8g_com_atmega_st7920_hw_spi_fn
#define U8G_COM_ST7920_HW_SPI u8g_com_atmega_st7920_hw_spi_fn
#endif
#endif
#if defined(__XTENSA__)
#define U8G_COM_HW_SPI u8g_com_esp8266_hw_spi_fn
#define U8G_COM_ST7920_HW_SPI u8g_com_null_fn
#endif
#endif
#endif
#ifndef U8G_COM_HW_SPI
#ifndef U8G_COM_HW_SPI
#define U8G_COM_HW_SPI u8g_com_null_fn
#define U8G_COM_HW_SPI u8g_com_null_fn
...
...
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