Merge pull request #509 from devsaurus/dev-irom0

Unify memory section usage for u8g
This commit is contained in:
Vowstar 2015-06-27 00:04:46 +08:00
commit d507060ecf
3 changed files with 5 additions and 50 deletions

View File

@ -26,21 +26,6 @@ typedef struct _lu8g_userdata_t lu8g_userdata_t;
#define LU8G (&(lud->u8g)) #define LU8G (&(lud->u8g))
// function to read 4-byte aligned from program memory AKA irom0
u8g_pgm_uint8_t ICACHE_FLASH_ATTR u8g_pgm_read(const u8g_pgm_uint8_t *adr)
{
uint32_t iadr = (uint32_t)adr;
// set up pointer to 4-byte aligned memory location
uint32_t *ptr = (uint32_t *)(iadr & ~0x3);
// read 4-byte aligned
uint32_t pgm_data = *ptr;
// return the correct byte within the retrieved 32bit word
return pgm_data >> ((iadr % 4) * 8);
}
// helper function: retrieve and check userdata argument // helper function: retrieve and check userdata argument
static lu8g_userdata_t *get_lud( lua_State *L ) static lu8g_userdata_t *get_lud( lua_State *L )
{ {
@ -889,22 +874,12 @@ uint8_t u8g_com_esp8266_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
break; break;
case U8G_COM_MSG_WRITE_SEQ: 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: case U8G_COM_MSG_WRITE_SEQ_P:
{ {
register uint8_t *ptr = arg_ptr; register uint8_t *ptr = arg_ptr;
while( arg_val > 0 ) while( arg_val > 0 )
{ {
platform_spi_send_recv( 1, u8g_pgm_read(ptr) ); platform_spi_send_recv( 1, *ptr++ );
ptr++;
arg_val--; arg_val--;
} }
} }
@ -957,6 +932,7 @@ uint8_t u8g_com_esp8266_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, voi
break; break;
case U8G_COM_MSG_WRITE_SEQ: case U8G_COM_MSG_WRITE_SEQ:
case U8G_COM_MSG_WRITE_SEQ_P:
//u8g->pin_list[U8G_PI_SET_A0] = 1; //u8g->pin_list[U8G_PI_SET_A0] = 1;
if ( u8g_com_esp8266_ssd_start_sequence(u8g) == 0 ) if ( u8g_com_esp8266_ssd_start_sequence(u8g) == 0 )
return platform_i2c_send_stop( ESP_I2C_ID ), 0; return platform_i2c_send_stop( ESP_I2C_ID ), 0;
@ -973,24 +949,6 @@ uint8_t u8g_com_esp8266_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, voi
// platform_i2c_send_stop( ESP_I2C_ID ); // platform_i2c_send_stop( ESP_I2C_ID );
break; break;
case U8G_COM_MSG_WRITE_SEQ_P:
//u8g->pin_list[U8G_PI_SET_A0] = 1;
if ( u8g_com_esp8266_ssd_start_sequence(u8g) == 0 )
return platform_i2c_send_stop( ESP_I2C_ID ), 0;
{
register uint8_t *ptr = arg_ptr;
while( arg_val > 0 )
{
// ignore return value -> tolerate missing ACK
if ( platform_i2c_send_byte( ESP_I2C_ID, u8g_pgm_read(ptr) ) == 0 )
; //return 0;
ptr++;
arg_val--;
}
}
// platform_i2c_send_stop( ESP_I2C_ID );
break;
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */ case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
u8g->pin_list[U8G_PI_A0_STATE] = arg_val; u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
u8g->pin_list[U8G_PI_SET_A0] = 1; /* force a0 to set again */ u8g->pin_list[U8G_PI_SET_A0] = 1; /* force a0 to set again */

View File

@ -88,7 +88,7 @@ extern "C" {
# define U8G_FONT_SECTION(name) U8G_SECTION(".progmem." name) # define U8G_FONT_SECTION(name) U8G_SECTION(".progmem." name)
# endif # endif
# if defined(__XTENSA__) # if defined(__XTENSA__)
# define U8G_FONT_SECTION(name) U8G_SECTION(".u8g_progmem." name) # define U8G_FONT_SECTION(name)
# endif # endif
#else #else
# define U8G_NOINLINE # define U8G_NOINLINE
@ -116,10 +116,10 @@ typedef uint8_t u8g_fntpgm_uint8_t;
#elif defined(__XTENSA__) #elif defined(__XTENSA__)
# define U8G_PROGMEM # define U8G_PROGMEM
# define PROGMEM U8G_SECTION(".u8g_progmem.data") # define PROGMEM
typedef uint8_t u8g_pgm_uint8_t; typedef uint8_t u8g_pgm_uint8_t;
typedef uint8_t u8g_fntpgm_uint8_t; typedef uint8_t u8g_fntpgm_uint8_t;
u8g_pgm_uint8_t u8g_pgm_read(const u8g_pgm_uint8_t *adr); # define u8g_pgm_read(adr) (*(const u8g_pgm_uint8_t *)(adr))
# define U8G_PSTR(s) ((u8g_pgm_uint8_t *)(s)) # define U8G_PSTR(s) ((u8g_pgm_uint8_t *)(s))
#else #else

View File

@ -72,9 +72,6 @@ SECTIONS
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text) *(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
*(.literal.* .text.*) *(.literal.* .text.*)
/* put font and progmem data into irom0 */
*(.u8g_progmem.*)
/* Trade some performance for lots of ram. At the time of writing the /* Trade some performance for lots of ram. At the time of writing the
* available Lua heap went from 18248 to 34704. */ * available Lua heap went from 18248 to 34704. */
*(.rodata*) *(.rodata*)