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
19092712
Commit
19092712
authored
Oct 11, 2015
by
devsaurus
Browse files
remove obsolete spi_mast_send and rename platform_spi_send
parent
c3680f82
Changes
7
Hide whitespace changes
Inline
Side-by-side
app/driver/spi.c
View file @
19092712
...
...
@@ -132,26 +132,6 @@ void spi_master_init(uint8 spi_no, unsigned cpol, unsigned cpha, uint32_t clock_
((
7
&
SPI_USR_MISO_BITLEN
)
<<
SPI_USR_MISO_BITLEN_S
));
}
/******************************************************************************
* FunctionName : spi_mast_byte_write
* Description : SPI master 1 byte transmission function
* Parameters : uint8 spi_no - SPI module number, Only "SPI" and "HSPI" are valid
* uint8 data- transmitted data
*******************************************************************************/
void
spi_mast_byte_write
(
uint8
spi_no
,
uint8
*
data
)
{
if
(
spi_no
>
1
)
return
;
//handle invalid input number
while
(
READ_PERI_REG
(
SPI_CMD
(
spi_no
))
&
SPI_USR
);
WRITE_PERI_REG
(
SPI_W0
(
spi_no
),
*
data
);
SET_PERI_REG_MASK
(
SPI_CMD
(
spi_no
),
SPI_USR
);
while
(
READ_PERI_REG
(
SPI_CMD
(
spi_no
))
&
SPI_USR
);
*
data
=
(
uint8
)(
READ_PERI_REG
(
SPI_W0
(
spi_no
))
&
0xff
);
}
/******************************************************************************
* FunctionName : spi_mast_set_mosi
* Description : Enter provided data into MOSI buffer.
...
...
app/include/driver/spi.h
View file @
19092712
...
...
@@ -19,11 +19,11 @@ void spi_lcd_9bit_write(uint8 spi_no,uint8 high_bit,uint8 low_8bit);
//spi master init funtion
void
spi_master_init
(
uint8
spi_no
,
unsigned
cpol
,
unsigned
cpha
,
uint32_t
clock_div
);
//use spi send 8bit data
void
spi_mast_byte_write
(
uint8
spi_no
,
uint8
*
data
);
// fill MOSI buffer
void
spi_set_mosi
(
uint8
spi_no
,
uint8
offset
,
uint8
bitlen
,
uint32
data
);
// retrieve data from MISO buffer
uint32
spi_get_miso
(
uint8
spi_no
,
uint8
offset
,
uint8
bitlen
);
// initiate SPI transaction
void
spi_mast_transaction
(
uint8
spi_no
,
uint8
cmd_bitlen
,
uint16
cmd_data
,
uint8
addr_bitlen
,
uint32
addr_data
,
uint8
mosi_bitlen
,
uint8
dummy_bitlen
,
uint8
miso_bitlen
);
...
...
app/modules/spi.c
View file @
19092712
...
...
@@ -58,7 +58,7 @@ static int spi_send( lua_State *L )
for
(
argn
=
3
;
argn
<=
lua_gettop
(
L
);
argn
++
)
{
numdata
=
(
u32
)
luaL_checkinteger
(
L
,
argn
);
if
(
PLATFORM_OK
!=
platform_spi_
transaction
(
id
,
0
,
0
,
bitlen
,
numdata
,
0
,
0
,
0
))
{
if
(
PLATFORM_OK
!=
platform_spi_
send
(
id
,
bitlen
,
numdata
))
{
return
luaL_error
(
L
,
"failed"
);
}
wrote
++
;
...
...
app/modules/u8g.c
View file @
19092712
...
...
@@ -861,7 +861,7 @@ uint8_t u8g_com_esp8266_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
break
;
case
U8G_COM_MSG_WRITE_BYTE
:
platform_spi_send
_recv
(
1
,
arg_val
);
platform_spi_send
(
1
,
8
,
arg_val
);
break
;
case
U8G_COM_MSG_WRITE_SEQ
:
...
...
@@ -870,7 +870,7 @@ uint8_t u8g_com_esp8266_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
register
uint8_t
*
ptr
=
arg_ptr
;
while
(
arg_val
>
0
)
{
platform_spi_send
_recv
(
1
,
*
ptr
++
);
platform_spi_send
(
1
,
8
,
*
ptr
++
);
arg_val
--
;
}
}
...
...
app/modules/ucg.c
View file @
19092712
...
...
@@ -752,36 +752,36 @@ static int16_t ucg_com_esp8266_hw_spi(ucg_t *ucg, int16_t msg, uint16_t arg, uin
break
;
case
UCG_COM_MSG_SEND_BYTE
:
platform_spi_send
_recv
(
1
,
arg
);
platform_spi_send
(
1
,
8
,
arg
);
break
;
case
UCG_COM_MSG_REPEAT_1_BYTE
:
while
(
arg
>
0
)
{
platform_spi_send
_recv
(
1
,
data
[
0
]
);
platform_spi_send
(
1
,
8
,
data
[
0
]
);
arg
--
;
}
break
;
case
UCG_COM_MSG_REPEAT_2_BYTES
:
while
(
arg
>
0
)
{
platform_spi_send
_recv
(
1
,
data
[
0
]
);
platform_spi_send
_recv
(
1
,
data
[
1
]
);
platform_spi_send
(
1
,
8
,
data
[
0
]
);
platform_spi_send
(
1
,
8
,
data
[
1
]
);
arg
--
;
}
break
;
case
UCG_COM_MSG_REPEAT_3_BYTES
:
while
(
arg
>
0
)
{
platform_spi_send
_recv
(
1
,
data
[
0
]
);
platform_spi_send
_recv
(
1
,
data
[
1
]
);
platform_spi_send
_recv
(
1
,
data
[
2
]
);
platform_spi_send
(
1
,
8
,
data
[
0
]
);
platform_spi_send
(
1
,
8
,
data
[
1
]
);
platform_spi_send
(
1
,
8
,
data
[
2
]
);
arg
--
;
}
break
;
case
UCG_COM_MSG_SEND_STR
:
while
(
arg
>
0
)
{
platform_spi_send
_recv
(
1
,
*
data
++
);
platform_spi_send
(
1
,
8
,
*
data
++
);
arg
--
;
}
break
;
...
...
@@ -802,7 +802,7 @@ static int16_t ucg_com_esp8266_hw_spi(ucg_t *ucg, int16_t msg, uint16_t arg, uin
}
}
data
++
;
platform_spi_send
_recv
(
1
,
*
data
);
platform_spi_send
(
1
,
8
,
*
data
);
data
++
;
arg
--
;
}
...
...
app/platform/platform.c
View file @
19092712
...
...
@@ -437,16 +437,20 @@ int platform_i2c_recv_byte( unsigned id, int ack ){
// *****************************************************************************
// SPI platform interface
uint32_t
platform_spi_setup
(
u
nsigned
id
,
int
mode
,
unsigned
cpol
,
unsigned
cpha
,
uint32_t
clock_div
)
uint32_t
platform_spi_setup
(
u
int8_t
id
,
int
mode
,
unsigned
cpol
,
unsigned
cpha
,
uint32_t
clock_div
)
{
spi_master_init
(
id
,
cpol
,
cpha
,
clock_div
);
return
1
;
}
spi_data_type
platform_spi_send
_recv
(
unsigned
id
,
spi_data_type
data
)
int
platform_spi_send
(
uint8_t
id
,
uint8_t
bitlen
,
spi_data_type
data
)
{
spi_mast_byte_write
(
id
,
&
data
);
return
data
;
if
(
bitlen
>
32
)
return
PLATFORM_ERR
;
spi_mast_transaction
(
id
,
0
,
0
,
bitlen
,
data
,
0
,
0
,
0
);
return
PLATFORM_OK
;
}
int
platform_spi_set_mosi
(
uint8_t
id
,
uint8_t
offset
,
uint8_t
bitlen
,
spi_data_type
data
)
...
...
app/platform/platform.h
View file @
19092712
...
...
@@ -96,8 +96,8 @@ typedef uint32_t spi_data_type;
// The platform SPI functions
int
platform_spi_exists
(
unsigned
id
);
uint32_t
platform_spi_setup
(
u
nsigned
id
,
int
mode
,
unsigned
cpol
,
unsigned
cpha
,
uint32_t
clock_div
);
spi_data_type
platform_spi_send
_recv
(
unsigned
id
,
spi_data_type
data
);
uint32_t
platform_spi_setup
(
u
int8_t
id
,
int
mode
,
unsigned
cpol
,
unsigned
cpha
,
uint32_t
clock_div
);
int
platform_spi_send
(
uint8_t
id
,
uint8_t
bitlen
,
spi_data_type
data
);
void
platform_spi_select
(
unsigned
id
,
int
is_select
);
int
platform_spi_set_mosi
(
uint8_t
id
,
uint8_t
offset
,
uint8_t
bitlen
,
spi_data_type
data
);
...
...
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