Opening brace tweaks

This commit is contained in:
Scott Lahteine 2017-12-25 09:29:41 -06:00
parent a142fab155
commit 1a827d5b68
11 changed files with 39 additions and 77 deletions

View File

@ -61,13 +61,11 @@
#include <Arduino.h> #include <Arduino.h>
#include "../../core/macros.h" #include "../../core/macros.h"
void u8g_SetPIOutput_DUE(u8g_t *u8g, uint8_t pin_index) { void u8g_SetPIOutput_DUE(u8g_t *u8g, uint8_t pin_index) {
PIO_Configure(g_APinDescription[u8g->pin_list[pin_index]].pPort, PIO_OUTPUT_1, PIO_Configure(g_APinDescription[u8g->pin_list[pin_index]].pPort, PIO_OUTPUT_1,
g_APinDescription[u8g->pin_list[pin_index]].ulPin, g_APinDescription[u8g->pin_list[pin_index]].ulPinConfiguration); // OUTPUT g_APinDescription[u8g->pin_list[pin_index]].ulPin, g_APinDescription[u8g->pin_list[pin_index]].ulPinConfiguration); // OUTPUT
} }
void u8g_SetPILevel_DUE(u8g_t *u8g, uint8_t pin_index, uint8_t level) { void u8g_SetPILevel_DUE(u8g_t *u8g, uint8_t pin_index, uint8_t level) {
volatile Pio* port = g_APinDescription[u8g->pin_list[pin_index]].pPort; volatile Pio* port = g_APinDescription[u8g->pin_list[pin_index]].pPort;
uint32_t mask = g_APinDescription[u8g->pin_list[pin_index]].ulPin; uint32_t mask = g_APinDescription[u8g->pin_list[pin_index]].ulPin;
@ -75,7 +73,6 @@
else port->PIO_CODR = mask; else port->PIO_CODR = mask;
} }
#define nop() __asm__ __volatile__("nop;\n\t":::) #define nop() __asm__ __volatile__("nop;\n\t":::)
void __delay_4cycles(uint32_t cy) __attribute__ ((weak)); void __delay_4cycles(uint32_t cy) __attribute__ ((weak));
@ -102,8 +99,7 @@ FORCE_INLINE void __delay_4cycles(uint32_t cy) { // +1 cycle
Pio *SCK_pPio, *MOSI_pPio; Pio *SCK_pPio, *MOSI_pPio;
uint32_t SCK_dwMask, MOSI_dwMask; uint32_t SCK_dwMask, MOSI_dwMask;
static void spiSend_sw_DUE(uint8_t val) // 800KHz static void spiSend_sw_DUE(uint8_t val) { // 800KHz
{
for (uint8_t i = 0; i < 8; i++) { for (uint8_t i = 0; i < 8; i++) {
if (val & 0x80) if (val & 0x80)
MOSI_pPio->PIO_SODR = MOSI_dwMask; MOSI_pPio->PIO_SODR = MOSI_dwMask;
@ -119,8 +115,7 @@ FORCE_INLINE void __delay_4cycles(uint32_t cy) { // +1 cycle
static uint8_t rs_last_state = 255; static uint8_t rs_last_state = 255;
static void u8g_com_DUE_st7920_write_byte_sw_spi(uint8_t rs, uint8_t val) static void u8g_com_DUE_st7920_write_byte_sw_spi(uint8_t rs, uint8_t val) {
{
uint8_t i; uint8_t i;
if ( rs != rs_last_state) { // time to send a command/data byte if ( rs != rs_last_state) { // time to send a command/data byte
@ -142,10 +137,8 @@ FORCE_INLINE void __delay_4cycles(uint32_t cy) { // +1 cycle
} }
uint8_t u8g_com_HAL_DUE_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) uint8_t u8g_com_HAL_DUE_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
{ switch (msg) {
switch(msg)
{
case U8G_COM_MSG_INIT: case U8G_COM_MSG_INIT:
SCK_pPio = g_APinDescription[u8g->pin_list[U8G_PI_SCK]].pPort; SCK_pPio = g_APinDescription[u8g->pin_list[U8G_PI_SCK]].pPort;
SCK_dwMask = g_APinDescription[u8g->pin_list[U8G_PI_SCK]].ulPin; SCK_dwMask = g_APinDescription[u8g->pin_list[U8G_PI_SCK]].ulPin;
@ -184,22 +177,18 @@ FORCE_INLINE void __delay_4cycles(uint32_t cy) { // +1 cycle
u8g_com_DUE_st7920_write_byte_sw_spi(u8g->pin_list[U8G_PI_A0_STATE], arg_val); u8g_com_DUE_st7920_write_byte_sw_spi(u8g->pin_list[U8G_PI_A0_STATE], arg_val);
break; break;
case U8G_COM_MSG_WRITE_SEQ: case U8G_COM_MSG_WRITE_SEQ: {
{
uint8_t *ptr = (uint8_t*) arg_ptr; uint8_t *ptr = (uint8_t*) arg_ptr;
while( arg_val > 0 ) while (arg_val > 0) {
{
u8g_com_DUE_st7920_write_byte_sw_spi(u8g->pin_list[U8G_PI_A0_STATE], *ptr++); u8g_com_DUE_st7920_write_byte_sw_spi(u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
arg_val--; arg_val--;
} }
} }
break; break;
case U8G_COM_MSG_WRITE_SEQ_P: case U8G_COM_MSG_WRITE_SEQ_P: {
{
uint8_t *ptr = (uint8_t*) arg_ptr; uint8_t *ptr = (uint8_t*) arg_ptr;
while( arg_val > 0 ) while (arg_val > 0) {
{
u8g_com_DUE_st7920_write_byte_sw_spi(u8g->pin_list[U8G_PI_A0_STATE], *ptr++); u8g_com_DUE_st7920_write_byte_sw_spi(u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
arg_val--; arg_val--;
} }
@ -208,5 +197,7 @@ FORCE_INLINE void __delay_4cycles(uint32_t cy) { // +1 cycle
} }
return 1; return 1;
} }
#pragma GCC reset_options #pragma GCC reset_options
#endif //ARDUINO_ARCH_SAM #endif //ARDUINO_ARCH_SAM

View File

@ -118,22 +118,18 @@
spiSend((uint8_t)arg_val); spiSend((uint8_t)arg_val);
break; break;
case U8G_COM_MSG_WRITE_SEQ: case U8G_COM_MSG_WRITE_SEQ: {
{
uint8_t *ptr = (uint8_t*) arg_ptr; uint8_t *ptr = (uint8_t*) arg_ptr;
while( arg_val > 0 ) while (arg_val > 0) {
{
spiSend(*ptr++); spiSend(*ptr++);
arg_val--; arg_val--;
} }
} }
break; break;
case U8G_COM_MSG_WRITE_SEQ_P: case U8G_COM_MSG_WRITE_SEQ_P: {
{
uint8_t *ptr = (uint8_t*) arg_ptr; uint8_t *ptr = (uint8_t*) arg_ptr;
while( arg_val > 0 ) while (arg_val > 0) {
{
spiSend(*ptr++); spiSend(*ptr++);
arg_val--; arg_val--;
} }

View File

@ -160,8 +160,7 @@
return u8g_i2c_stop(), 0; return u8g_i2c_stop(), 0;
{ {
register uint8_t *ptr = (uint8_t *)arg_ptr; register uint8_t *ptr = (uint8_t *)arg_ptr;
while( arg_val > 0 ) while (arg_val > 0) {
{
if ( u8g_i2c_send_byte(*ptr++) == 0 ) if ( u8g_i2c_send_byte(*ptr++) == 0 )
return u8g_i2c_stop(), 0; return u8g_i2c_stop(), 0;
arg_val--; arg_val--;
@ -176,8 +175,7 @@
return u8g_i2c_stop(), 0; return u8g_i2c_stop(), 0;
{ {
register uint8_t *ptr = (uint8_t *)arg_ptr; register uint8_t *ptr = (uint8_t *)arg_ptr;
while( arg_val > 0 ) while (arg_val > 0) {
{
if ( u8g_i2c_send_byte(u8g_pgm_read(ptr)) == 0 ) if ( u8g_i2c_send_byte(u8g_pgm_read(ptr)) == 0 )
return 0; return 0;
ptr++; ptr++;

View File

@ -239,8 +239,7 @@ void u8g_i2c_init_sw(uint8_t clock_option) {
return u8g_i2c_stop_sw(), 0; return u8g_i2c_stop_sw(), 0;
{ {
register uint8_t *ptr = (uint8_t *)arg_ptr; register uint8_t *ptr = (uint8_t *)arg_ptr;
while( arg_val > 0 ) while (arg_val > 0) {
{
if ( u8g_i2c_send_byte_sw(*ptr++) == 0 ) if ( u8g_i2c_send_byte_sw(*ptr++) == 0 )
return u8g_i2c_stop_sw(), 0; return u8g_i2c_stop_sw(), 0;
arg_val--; arg_val--;
@ -255,8 +254,7 @@ void u8g_i2c_init_sw(uint8_t clock_option) {
return u8g_i2c_stop_sw(), 0; return u8g_i2c_stop_sw(), 0;
{ {
register uint8_t *ptr = (uint8_t *)arg_ptr; register uint8_t *ptr = (uint8_t *)arg_ptr;
while( arg_val > 0 ) while (arg_val > 0) {
{
if ( u8g_i2c_send_byte_sw(u8g_pgm_read(ptr)) == 0 ) if ( u8g_i2c_send_byte_sw(u8g_pgm_read(ptr)) == 0 )
return 0; return 0;
ptr++; ptr++;

View File

@ -136,22 +136,18 @@
u8g_com_LPC1768_st7920_write_byte_hw_spi(u8g->pin_list[U8G_PI_A0_STATE], arg_val); u8g_com_LPC1768_st7920_write_byte_hw_spi(u8g->pin_list[U8G_PI_A0_STATE], arg_val);
break; break;
case U8G_COM_MSG_WRITE_SEQ: case U8G_COM_MSG_WRITE_SEQ: {
{
uint8_t *ptr = (uint8_t*) arg_ptr; uint8_t *ptr = (uint8_t*) arg_ptr;
while( arg_val > 0 ) while (arg_val > 0) {
{
u8g_com_LPC1768_st7920_write_byte_hw_spi(u8g->pin_list[U8G_PI_A0_STATE], *ptr++); u8g_com_LPC1768_st7920_write_byte_hw_spi(u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
arg_val--; arg_val--;
} }
} }
break; break;
case U8G_COM_MSG_WRITE_SEQ_P: case U8G_COM_MSG_WRITE_SEQ_P: {
{
uint8_t *ptr = (uint8_t*) arg_ptr; uint8_t *ptr = (uint8_t*) arg_ptr;
while( arg_val > 0 ) while (arg_val > 0) {
{
u8g_com_LPC1768_st7920_write_byte_hw_spi(u8g->pin_list[U8G_PI_A0_STATE], *ptr++); u8g_com_LPC1768_st7920_write_byte_hw_spi(u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
arg_val--; arg_val--;
} }

View File

@ -170,22 +170,18 @@
u8g_com_LPC1768_st7920_write_byte_sw_spi(u8g->pin_list[U8G_PI_A0_STATE], arg_val); u8g_com_LPC1768_st7920_write_byte_sw_spi(u8g->pin_list[U8G_PI_A0_STATE], arg_val);
break; break;
case U8G_COM_MSG_WRITE_SEQ: case U8G_COM_MSG_WRITE_SEQ: {
{
uint8_t *ptr = (uint8_t*) arg_ptr; uint8_t *ptr = (uint8_t*) arg_ptr;
while( arg_val > 0 ) while (arg_val > 0) {
{
u8g_com_LPC1768_st7920_write_byte_sw_spi(u8g->pin_list[U8G_PI_A0_STATE], *ptr++); u8g_com_LPC1768_st7920_write_byte_sw_spi(u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
arg_val--; arg_val--;
} }
} }
break; break;
case U8G_COM_MSG_WRITE_SEQ_P: case U8G_COM_MSG_WRITE_SEQ_P: {
{
uint8_t *ptr = (uint8_t*) arg_ptr; uint8_t *ptr = (uint8_t*) arg_ptr;
while( arg_val > 0 ) while (arg_val > 0) {
{
u8g_com_LPC1768_st7920_write_byte_sw_spi(u8g->pin_list[U8G_PI_A0_STATE], *ptr++); u8g_com_LPC1768_st7920_write_byte_sw_spi(u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
arg_val--; arg_val--;
} }

View File

@ -150,22 +150,18 @@ uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
u8g_sw_spi_HAL_LPC1768_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], arg_val); u8g_sw_spi_HAL_LPC1768_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], arg_val);
break; break;
case U8G_COM_MSG_WRITE_SEQ: case U8G_COM_MSG_WRITE_SEQ: {
{
uint8_t *ptr = (uint8_t *)arg_ptr; uint8_t *ptr = (uint8_t *)arg_ptr;
while( arg_val > 0 ) while (arg_val > 0) {
{
u8g_sw_spi_HAL_LPC1768_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], *ptr++); u8g_sw_spi_HAL_LPC1768_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], *ptr++);
arg_val--; arg_val--;
} }
} }
break; break;
case U8G_COM_MSG_WRITE_SEQ_P: case U8G_COM_MSG_WRITE_SEQ_P: {
{
uint8_t *ptr = (uint8_t *)arg_ptr; uint8_t *ptr = (uint8_t *)arg_ptr;
while( arg_val > 0 ) while (arg_val > 0) {
{
u8g_sw_spi_HAL_LPC1768_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], u8g_pgm_read(ptr)); u8g_sw_spi_HAL_LPC1768_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], u8g_pgm_read(ptr));
ptr++; ptr++;
arg_val--; arg_val--;

View File

@ -110,8 +110,7 @@ static void drv_status_print_hex(const char name[], const uint32_t drv_status) {
#if ENABLED(HAVE_TMC2208) #if ENABLED(HAVE_TMC2208)
static void tmc_status(TMC2208Stepper &st, const TMC_debug_enum i) { static void tmc_status(TMC2208Stepper &st, const TMC_debug_enum i) {
switch(i) { switch(i) {
case TMC_TSTEP: case TMC_TSTEP: {
{
uint32_t data = 0; uint32_t data = 0;
st.TSTEP(&data); st.TSTEP(&data);
MYSERIAL.print(data); MYSERIAL.print(data);
@ -159,14 +158,12 @@ static void tmc_status(TMC &st, TMC_AxisEnum axis, const TMC_debug_enum i, const
case TMC_VSENSE: serialprintPGM(st.vsense() ? PSTR("1=.18") : PSTR("0=.325")); break; case TMC_VSENSE: serialprintPGM(st.vsense() ? PSTR("1=.18") : PSTR("0=.325")); break;
case TMC_MICROSTEPS: SERIAL_ECHO(st.microsteps()); break; case TMC_MICROSTEPS: SERIAL_ECHO(st.microsteps()); break;
case TMC_TPWMTHRS: case TMC_TPWMTHRS: {
{
uint32_t tpwmthrs_val = st.TPWMTHRS(); uint32_t tpwmthrs_val = st.TPWMTHRS();
SERIAL_ECHO(tpwmthrs_val); SERIAL_ECHO(tpwmthrs_val);
} }
break; break;
case TMC_TPWMTHRS_MMS: case TMC_TPWMTHRS_MMS: {
{
uint32_t tpwmthrs_val = st.TPWMTHRS(); uint32_t tpwmthrs_val = st.TPWMTHRS();
tpwmthrs_val ? SERIAL_ECHO(12650000UL * st.microsteps() / (256 * tpwmthrs_val * spmm)) : SERIAL_ECHO('-'); tpwmthrs_val ? SERIAL_ECHO(12650000UL * st.microsteps() / (256 * tpwmthrs_val * spmm)) : SERIAL_ECHO('-');
} }

View File

@ -128,8 +128,7 @@ uint8_t u8g_dev_sh1106_128x64_2x_2_wire_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t m
break; break;
case U8G_DEV_MSG_STOP: case U8G_DEV_MSG_STOP:
break; break;
case U8G_DEV_MSG_PAGE_NEXT: case U8G_DEV_MSG_PAGE_NEXT: {
{
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem); u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
u8g_SetAddress(u8g, dev, 0); // instruction mode u8g_SetAddress(u8g, dev, 0); // instruction mode
u8g_WriteEscSeqP_2_wire(u8g, dev, u8g_dev_sh1106_128x64_data_start_2_wire); u8g_WriteEscSeqP_2_wire(u8g, dev, u8g_dev_sh1106_128x64_data_start_2_wire);
@ -202,8 +201,7 @@ uint8_t u8g_dev_ssd1306_128x64_2x_2_wire_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t
break; break;
case U8G_DEV_MSG_STOP: case U8G_DEV_MSG_STOP:
break; break;
case U8G_DEV_MSG_PAGE_NEXT: case U8G_DEV_MSG_PAGE_NEXT: {
{
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem); u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
u8g_SetAddress(u8g, dev, 0); // instruction mode u8g_SetAddress(u8g, dev, 0); // instruction mode
u8g_WriteEscSeqP_2_wire(u8g, dev, u8g_dev_ssd1306_128x64_data_start_2_wire); u8g_WriteEscSeqP_2_wire(u8g, dev, u8g_dev_ssd1306_128x64_data_start_2_wire);

View File

@ -149,8 +149,7 @@ uint8_t u8g_dev_st7565_64128n_HAL_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
break; break;
case U8G_DEV_MSG_STOP: case U8G_DEV_MSG_STOP:
break; break;
case U8G_DEV_MSG_PAGE_NEXT: case U8G_DEV_MSG_PAGE_NEXT: {
{
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem); u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_HAL_data_start); u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_HAL_data_start);
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */ u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
@ -187,8 +186,7 @@ uint8_t u8g_dev_st7565_64128n_HAL_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg,
break; break;
case U8G_DEV_MSG_STOP: case U8G_DEV_MSG_STOP:
break; break;
case U8G_DEV_MSG_PAGE_NEXT: case U8G_DEV_MSG_PAGE_NEXT: {
{
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem); u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_HAL_data_start); u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_HAL_data_start);

View File

@ -99,8 +99,7 @@ uint8_t u8g_dev_st7920_128x64_HAL_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
break; break;
case U8G_DEV_MSG_STOP: case U8G_DEV_MSG_STOP:
break; break;
case U8G_DEV_MSG_PAGE_NEXT: case U8G_DEV_MSG_PAGE_NEXT: {
{
uint8_t y, i; uint8_t y, i;
uint8_t *ptr; uint8_t *ptr;
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem); u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
@ -149,8 +148,7 @@ uint8_t u8g_dev_st7920_128x64_HAL_4x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg,
case U8G_DEV_MSG_STOP: case U8G_DEV_MSG_STOP:
break; break;
case U8G_DEV_MSG_PAGE_NEXT: case U8G_DEV_MSG_PAGE_NEXT: {
{
uint8_t y, i; uint8_t y, i;
uint8_t *ptr; uint8_t *ptr;
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem); u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);