nrf: Clean up source by removing tabs, trailing spaces, non-ASCII chars.

pull/5003/head
Damien George 2019-08-28 13:34:45 +10:00
rodzic 5635b96461
commit 1fe1ff935b
21 zmienionych plików z 70 dodań i 71 usunięć

Wyświetl plik

@ -16,7 +16,7 @@ SECTIONS
. = ALIGN(4);
_etext = .; /* define a global symbol at end of code */
} >FLASH_TEXT
/*
.ARM.extab :
{
@ -30,10 +30,10 @@ SECTIONS
__exidx_end = .;
} >FLASH
*/
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);
/* This is the initialized data section
The program executes knowing that the data is in the RAM
but the loader puts the initial values in the FLASH (inidata).
@ -49,7 +49,7 @@ SECTIONS
. = ALIGN(4);
_edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
} >RAM AT>FLASH_TEXT
/* Uninitialized data section */
.bss :
{

Wyświetl plik

@ -256,15 +256,15 @@ static const uint16_t render_timings[] =
// The scale is (approximately) exponential,
// each step is approx x1.9 greater than the previous.
{ 0, // Bright, Ticks Duration, Relative power
2, // 1, 2, 32µs, inf
2, // 2, 4, 64µs, 200%
4, // 3, 8, 128µs, 200%
7, // 4, 15, 240µs, 187%
13, // 5, 28, 448µs, 187%
25, // 6, 53, 848µs, 189%
49, // 7, 102, 1632µs, 192%
97, // 8, 199, 3184µs, 195%
// Always on 9, 375, 6000µs, 188%
2, // 1, 2, 32us, inf
2, // 2, 4, 64us, 200%
4, // 3, 8, 128us, 200%
7, // 4, 15, 240us, 187%
13, // 5, 28, 448us, 187%
25, // 6, 53, 848us, 189%
49, // 7, 102, 1632us, 192%
97, // 8, 199, 3184us, 195%
// Always on 9, 375, 6000us, 188%
};
#define DISPLAY_TICKER_SLOT 1
@ -281,7 +281,7 @@ static int32_t callback(void) {
return -1;
}
display->previous_brightness = brightness;
// Return interval (in 16µs ticks) until next callback
// Return interval (in 16us ticks) until next callback
return render_timings[brightness];
}

Wyświetl plik

@ -62,7 +62,7 @@ STATIC void microbit_image_print(const mp_print_t *print, mp_obj_t self_in, mp_p
uint8_t monochromeGetPixelValue(monochrome_5by5_t * p_mono, mp_int_t x, mp_int_t y) {
unsigned int index = y*5+x;
if (index == 24)
if (index == 24)
return p_mono->pixel44;
return (p_mono->bits24[index>>3] >> (index&7))&1;
}
@ -380,7 +380,7 @@ mp_obj_t microbit_image_set_pixel(mp_uint_t n_args, const mp_obj_t *args) {
mp_raise_ValueError("index cannot be negative");
}
mp_int_t bright = mp_obj_get_int(args[3]);
if (bright < 0 || bright > MAX_BRIGHTNESS)
if (bright < 0 || bright > MAX_BRIGHTNESS)
mp_raise_ValueError("brightness out of bounds.");
if (x < imageWidth(self) && y < imageHeight(self)) {
greyscaleSetPixelValue(&(self->greyscale), x, y, bright);
@ -610,7 +610,7 @@ microbit_image_obj_t *microbit_image_dim(microbit_image_obj_t *lhs, mp_float_t f
#else
microbit_image_obj_t *microbit_image_dim(microbit_image_obj_t *lhs, mp_int_t fval) {
#endif
if (fval < 0)
if (fval < 0)
mp_raise_ValueError("Brightness multiplier must not be negative.");
greyscale_t *result = greyscale_new(imageWidth(lhs), imageHeight(lhs));
for (int x = 0; x < imageWidth(lhs); ++x) {
@ -639,7 +639,7 @@ microbit_image_obj_t *microbit_image_sum(microbit_image_obj_t *lhs, microbit_ima
int val;
int lval = imageGetPixelValue(lhs, x,y);
int rval = imageGetPixelValue(rhs, x,y);
if (add)
if (add)
val = min(lval + rval, MAX_BRIGHTNESS);
else
val = max(0, lval - rval);
@ -647,7 +647,7 @@ microbit_image_obj_t *microbit_image_sum(microbit_image_obj_t *lhs, microbit_ima
}
}
return (microbit_image_obj_t *)result;
}
}
STATIC mp_obj_t image_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
if (mp_obj_get_type(lhs_in) != &microbit_image_type) {
@ -697,9 +697,9 @@ const mp_obj_type_t microbit_image_type = {
.buffer_p = {NULL},
.locals_dict = (mp_obj_dict_t*)&microbit_image_locals_dict,
};
typedef struct _scrolling_string_t {
mp_obj_base_t base;
mp_obj_base_t base;
char const *str;
mp_uint_t len;
mp_obj_t ref;
@ -708,7 +708,7 @@ typedef struct _scrolling_string_t {
} scrolling_string_t;
typedef struct _scrolling_string_iterator_t {
mp_obj_base_t base;
mp_obj_base_t base;
mp_obj_t ref;
greyscale_t *img;
char const *next_char;
@ -962,7 +962,7 @@ const mp_obj_type_t microbit_facade_iterator_type = {
};
mp_obj_t microbit_facade_iterator(mp_obj_t iterable_in, mp_obj_iter_buf_t *iter_buf) {
(void)iter_buf;
(void)iter_buf;
facade_iterator_t *result = m_new_obj(facade_iterator_t);
string_image_facade_t *iterable = (string_image_facade_t *)iterable_in;
result->base.type = &microbit_facade_iterator_type;

Wyświetl plik

@ -2,15 +2,15 @@
#define __MICROPY_INCLUDED_MICROBIT_IMAGE_H__
#include "py/runtime.h"
#define MAX_BRIGHTNESS 9
/** Monochrome images are immutable, which means that
/** Monochrome images are immutable, which means that
* we only need one bit per pixel which saves quite a lot
* of memory */
/* we reserve a couple of bits, so we won't need to modify the
* layout if we need to add more functionality or subtypes. */
* layout if we need to add more functionality or subtypes. */
#define TYPE_AND_FLAGS \
mp_obj_base_t base; \
uint8_t five:1; \

Wyświetl plik

@ -48,8 +48,8 @@ void Reset_Handler(void) {
// RAM on in on-mode
*ram_on_addr = 3; // block 0 and 1
*ram_on_b_addr = 3; // block 2 and 3
#if 0
// RAM on in off-mode
#if 0
// RAM on in off-mode
ram_on_addr = 1 << 16;
ram_on_b_addr = 1 << 17;
#endif

Wyświetl plik

@ -418,7 +418,7 @@ bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) {
p_adv_params->p_device_name,
p_adv_params->device_name_len) != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
"Can not apply device name in the stack."));
"Can not apply device name in the stack."));
}
BLE_DRIVER_LOG("Device name applied\n");

Wyświetl plik

@ -190,7 +190,7 @@ void ble_uart_init0(void) {
ble_uart_char_tx.service_handle = ble_uart_service.handle;
bool retval = ble_drv_characteristic_add(&ble_uart_char_tx);
if (retval) {
ble_uart_char_tx.p_service = &ble_uart_service;
ble_uart_char_tx.p_service = &ble_uart_service;
}
mp_obj_list_append(ble_uart_service.char_list, MP_OBJ_FROM_PTR(&ble_uart_char_tx));
@ -198,7 +198,7 @@ void ble_uart_init0(void) {
ble_uart_char_rx.service_handle = ble_uart_service.handle;
retval = ble_drv_characteristic_add(&ble_uart_char_rx);
if (retval) {
ble_uart_char_rx.p_service = &ble_uart_service;
ble_uart_char_rx.p_service = &ble_uart_service;
}
mp_obj_list_append(ble_uart_service.char_list, MP_OBJ_FROM_PTR(&ble_uart_char_rx));

Wyświetl plik

@ -35,7 +35,7 @@
#define __MICROPY_INCLUDED_LIB_TICKER_H__
/*************************************
* 62.5kHz (16µs cycle time) ticker.
* 62.5kHz (16us cycle time) ticker.
************************************/
#include "nrf.h"

Wyświetl plik

@ -28,6 +28,6 @@
#include "lib/oofatfs/ff.h"
DWORD get_fattime(void) {
// TODO: Implement this function. For now, fake it.
// TODO: Implement this function. For now, fake it.
return ((2016 - 1980) << 25) | ((12) << 21) | ((4) << 16) | ((00) << 11) | ((18) << 5) | (23 / 2);
}

Wyświetl plik

@ -94,7 +94,7 @@ extern uint32_t _heap_start;
extern uint32_t _heap_end;
int main(int argc, char **argv) {
soft_reset:
mp_stack_set_top(&_ram_end);
@ -185,8 +185,8 @@ pin_init0();
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_sd));
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_sd_slash_lib));
// use SD card as current directory
f_chdrive("/sd");
// use SD card as current directory
f_chdrive("/sd");
}
no_mem_for_sd:;
}
@ -293,18 +293,17 @@ MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, mp_builtin_open);
void HardFault_Handler(void)
{
#if defined(NRF52_SERIES)
static volatile uint32_t reg;
static volatile uint32_t reg2;
static volatile uint32_t bfar;
reg = SCB->HFSR;
reg2 = SCB->CFSR;
bfar = SCB->BFAR;
for (int i = 0; i < 0; i++)
{
(void)reg;
(void)reg2;
(void)bfar;
}
static volatile uint32_t reg;
static volatile uint32_t reg2;
static volatile uint32_t bfar;
reg = SCB->HFSR;
reg2 = SCB->CFSR;
bfar = SCB->BFAR;
for (int i = 0; i < 0; i++) {
(void)reg;
(void)reg2;
(void)bfar;
}
#endif
}

Wyświetl plik

@ -39,7 +39,7 @@
" ble.enabled() -- check whether bluetooth stack is enabled\n" \
" ble.address() -- return device address as text string\n" \
"\n"
#else
#define HELP_TEXT_SD
#endif // MICROPY_PY_BLE

Wyświetl plik

@ -127,12 +127,12 @@ const pin_obj_t *pin_find(mp_obj_t user_obj) {
const pin_obj_t *pin_obj;
// If pin is SMALL_INT
if (mp_obj_is_small_int(user_obj)) {
uint8_t value = MP_OBJ_SMALL_INT_VALUE(user_obj);
uint8_t value = MP_OBJ_SMALL_INT_VALUE(user_obj);
for (uint8_t i = 0; i < machine_pin_num_of_pins; i++) {
if (machine_pin_obj[i].pin == value) {
return &machine_pin_obj[i];
}
}
}
}
}
// If a pin was provided, then use it
@ -364,8 +364,8 @@ STATIC mp_obj_t pin_obj_init_helper(const pin_obj_t *self, mp_uint_t n_args, con
nrf_gpio_pin_dir_t mode = (nrf_gpio_pin_dir_t)args[0].u_int;
// Connect input or not
nrf_gpio_pin_input_t input = (mode == NRF_GPIO_PIN_DIR_INPUT) ? NRF_GPIO_PIN_INPUT_CONNECT
: NRF_GPIO_PIN_INPUT_DISCONNECT;
nrf_gpio_pin_input_t input = (mode == NRF_GPIO_PIN_DIR_INPUT) ? NRF_GPIO_PIN_INPUT_CONNECT
: NRF_GPIO_PIN_INPUT_DISCONNECT;
if (mode == NRF_GPIO_PIN_DIR_OUTPUT || mode == NRF_GPIO_PIN_DIR_INPUT) {
nrf_gpio_cfg(self->pin,
@ -496,7 +496,7 @@ STATIC void pin_common_irq_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t
}
STATIC mp_obj_t pin_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum {ARG_handler, ARG_trigger, ARG_wake};
enum {ARG_handler, ARG_trigger, ARG_wake};
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_handler, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = mp_const_none} },
{ MP_QSTR_trigger, MP_ARG_INT, {.u_int = NRF_GPIOTE_POLARITY_LOTOHI | NRF_GPIOTE_POLARITY_HITOLO} },

Wyświetl plik

@ -269,7 +269,7 @@ STATIC mp_obj_t machine_hard_pwm_make_new(mp_arg_val_t *args) {
} else {
self->p_config->mode = MODE_HIGH_LOW;
}
return MP_OBJ_FROM_PTR(self);
}

Wyświetl plik

@ -154,9 +154,9 @@ STATIC int spi_find(mp_obj_t id) {
void spi_transfer(const machine_hard_spi_obj_t * self, size_t len, const void * src, void * dest) {
nrfx_spi_xfer_desc_t xfer_desc = {
.p_tx_buffer = src,
.tx_length = len,
.p_rx_buffer = dest,
.rx_length = len
.tx_length = len,
.p_rx_buffer = dest,
.rx_length = len
};
nrfx_spi_xfer(self->p_spi, &xfer_desc, 0);
@ -340,7 +340,7 @@ STATIC void machine_hard_spi_init(mp_obj_t self_in, mp_arg_val_t *args) {
// Active high
if (args[ARG_INIT_polarity].u_int == 0) {
if (args[ARG_INIT_phase].u_int == 0) {
if (args[ARG_INIT_phase].u_int == 0) {
// First clock edge
self->p_config->mode = NRF_SPI_MODE_0;
} else {
@ -349,7 +349,7 @@ STATIC void machine_hard_spi_init(mp_obj_t self_in, mp_arg_val_t *args) {
}
// Active low
} else {
if (args[ARG_INIT_phase].u_int == 0) {
if (args[ARG_INIT_phase].u_int == 0) {
// First clock edge
self->p_config->mode = NRF_SPI_MODE_2;
} else {

Wyświetl plik

@ -67,9 +67,9 @@ STATIC mp_obj_t machine_temp_make_new(const mp_obj_type_t *type, size_t n_args,
// parse args
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
machine_temp_obj_t *self = m_new_obj(machine_temp_obj_t);
self->base.type = &machine_temp_type;
return MP_OBJ_FROM_PTR(self);

Wyświetl plik

@ -72,7 +72,7 @@ uint32_t machine_rng_generate_random_word(void) {
status = sd_rand_application_vector_get((uint8_t *)&retval, 4); // Extract 4 bytes
} while (status != 0);
return retval;
return retval;
}
#endif

Wyświetl plik

@ -72,7 +72,7 @@ STATIC const mp_rom_map_elem_t ubluepy_delegate_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_handleConnection), MP_ROM_PTR(&ubluepy_delegate_handle_conn_obj) },
{ MP_ROM_QSTR(MP_QSTR_handleNotification), MP_ROM_PTR(&ubluepy_delegate_handle_notif_obj) },
#if 0
{ MP_ROM_QSTR(MP_QSTR_handleDiscovery), MP_ROM_PTR(&ubluepy_delegate_handle_disc_obj) },
{ MP_ROM_QSTR(MP_QSTR_handleDiscovery), MP_ROM_PTR(&ubluepy_delegate_handle_disc_obj) },
#endif
};

Wyświetl plik

@ -481,7 +481,7 @@ STATIC const mp_rom_map_elem_t ubluepy_peripheral_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_advertise), MP_ROM_PTR(&ubluepy_peripheral_advertise_obj) },
#endif
#if MICROPY_PY_UBLUEPY_OBSERVER
// Nothing yet.
// Nothing yet.
#endif
};

Wyświetl plik

@ -162,7 +162,7 @@ STATIC const mp_rom_map_elem_t ubluepy_service_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_addCharacteristic), MP_ROM_PTR(&ubluepy_service_add_char_obj) },
{ MP_ROM_QSTR(MP_QSTR_getCharacteristics), MP_ROM_PTR(&ubluepy_service_get_chars_obj) },
#if 0
// Properties
// Properties
{ MP_ROM_QSTR(MP_QSTR_peripheral), MP_ROM_PTR(&ubluepy_service_get_peripheral_obj) },
#endif
{ MP_ROM_QSTR(MP_QSTR_uuid), MP_ROM_PTR(&ubluepy_service_get_uuid_obj) },

Wyświetl plik

@ -42,7 +42,7 @@ typedef enum
} HAL_StatusTypeDef;
static inline uint32_t hal_tick_fake(void) {
return 0;
return 0;
}
#define mp_hal_ticks_ms hal_tick_fake // TODO: implement. Right now, return 0 always

Wyświetl plik

@ -53,9 +53,9 @@ enum {
};
#define PIN_DEFS_PORT_AF_UNION \
NRF_UART_Type *UART;
// NRF_SPI_Type *SPIM;
// NRF_SPIS_Type *SPIS;
NRF_UART_Type *UART;
// NRF_SPI_Type *SPIM;
// NRF_SPIS_Type *SPIS;
typedef NRF_GPIO_Type pin_gpio_t;