remove obsolete spi_mast_send and rename platform_spi_send

This commit is contained in:
devsaurus 2015-10-11 13:42:03 +02:00
parent c3680f8291
commit 19092712e5
7 changed files with 25 additions and 41 deletions

View File

@ -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.

View File

@ -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);

View File

@ -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 ++;

View File

@ -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--;
}
}

View File

@ -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--;
}

View File

@ -437,16 +437,20 @@ int platform_i2c_recv_byte( unsigned id, int ack ){
// *****************************************************************************
// SPI platform interface
uint32_t platform_spi_setup( unsigned id, int mode, unsigned cpol, unsigned cpha, uint32_t clock_div)
uint32_t platform_spi_setup( uint8_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 )

View File

@ -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( unsigned 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( uint8_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 );