diff --git a/targets/TARGET_Realtek/TARGET_AMEBA/analogin_api.c b/targets/TARGET_Realtek/TARGET_AMEBA/analogin_api.c index 05c4b0a887..011008d791 100644 --- a/targets/TARGET_Realtek/TARGET_AMEBA/analogin_api.c +++ b/targets/TARGET_Realtek/TARGET_AMEBA/analogin_api.c @@ -29,8 +29,8 @@ extern u32 ConfigDebugErr; extern u32 ConfigDebuginfo; -void analogin_init (analogin_t *obj, PinName pin){ - +void analogin_init (analogin_t *obj, PinName pin) +{ uint32_t adc_idx; PSAL_ADC_MNGT_ADPT pSalADCMngtAdpt = NULL; PSAL_ADC_USERCB_ADPT pSalADCUserCBAdpt = NULL; @@ -71,7 +71,6 @@ void analogin_init (analogin_t *obj, PinName pin){ /* To backup user config first */ //_memcpy(pHalADCInitDataTmp, &(obj->HalADCInitData), sizeof(HAL_ADC_INIT_DAT)); - pSalADCMngtAdpt->pHalInitDat = &(obj->HalADCInitData); pSalADCMngtAdpt->pHalOp = &(obj->HalADCOp); @@ -129,7 +128,8 @@ void analogin_init (analogin_t *obj, PinName pin){ RtkADCInit(pSalADCHND); } -float analogin_read(analogin_t *obj){ +float analogin_read(analogin_t *obj) +{ float value; uint32_t AnaloginTmp[2] = {0,0}; uint32_t AnaloginDatMsk = 0xFFFF; @@ -158,7 +158,8 @@ float analogin_read(analogin_t *obj){ return (float)value; } -uint16_t analogin_read_u16(analogin_t *obj){ +uint16_t analogin_read_u16(analogin_t *obj) +{ uint32_t AnaloginTmp[2] = {0,0}; uint32_t AnaloginDatMsk = 0xFFFF; uint8_t AnaloginIdx = 0; @@ -178,11 +179,11 @@ uint16_t analogin_read_u16(analogin_t *obj){ AnalogDat = (AnalogDat>>((u32)(16*(AnaloginIdx&0x01)))); return (uint16_t)AnalogDat; - } -void analogin_deinit(analogin_t *obj){ +void analogin_deinit(analogin_t *obj) +{ PSAL_ADC_MNGT_ADPT pSalADCMngtAdpt = NULL; PSAL_ADC_HND pSalADCHND = NULL; diff --git a/targets/TARGET_Realtek/TARGET_AMEBA/analogout_api.c b/targets/TARGET_Realtek/TARGET_AMEBA/analogout_api.c index 153e1a26bb..cefa7cfad1 100644 --- a/targets/TARGET_Realtek/TARGET_AMEBA/analogout_api.c +++ b/targets/TARGET_Realtek/TARGET_AMEBA/analogout_api.c @@ -34,7 +34,8 @@ * \para dac_t *: obj * \para PinName: pin */ -void analogout_init(dac_t *obj, PinName pin) { +void analogout_init(dac_t *obj, PinName pin) +{ uint32_t dac_idx; uint32_t DacTemp; PHAL_DAC_INIT_DAT pHalDacInitData = (PHAL_DAC_INIT_DAT)&(obj->DACpara); @@ -90,7 +91,8 @@ void analogout_init(dac_t *obj, PinName pin) { * This function is mainly to free a DAC channel. * \para dac_t *: obj */ -void analogout_free(dac_t *obj) { +void analogout_free(dac_t *obj) +{ PHAL_DAC_INIT_DAT pHalDacInitData = (PHAL_DAC_INIT_DAT)&(obj->DACpara); HalDACPinMuxDeInit(pHalDacInitData); @@ -110,7 +112,8 @@ void analogout_free(dac_t *obj) { * \para dac_t * : obj * \para float : value */ -void analogout_write(dac_t *obj, float value) { +void analogout_write(dac_t *obj, float value) +{ uint32_t dactemp; uint16_t dacnegtemp; PHAL_DAC_INIT_DAT pHalDacInitData = (PHAL_DAC_INIT_DAT)&(obj->DACpara); @@ -149,7 +152,8 @@ void analogout_write(dac_t *obj, float value) { * \para dac_t * : obj * \para float : value */ -void analogout_write_u16(dac_t *obj, uint16_t value) { +void analogout_write_u16(dac_t *obj, uint16_t value) +{ uint32_t dactemp; PHAL_DAC_INIT_DAT pHalDacInitData = (PHAL_DAC_INIT_DAT)&(obj->DACpara); @@ -165,7 +169,8 @@ void analogout_write_u16(dac_t *obj, uint16_t value) { * It always returns a fixed value of 0.0; * \para dac_t * : obj */ -float analogout_read(dac_t *obj) { +float analogout_read(dac_t *obj) +{ return (float)0.0; } @@ -176,7 +181,8 @@ float analogout_read(dac_t *obj) { * It always returns a fixed value of 0xFFFF; * \para dac_t * : obj */ -uint16_t analogout_read_u16(dac_t *obj) { +uint16_t analogout_read_u16(dac_t *obj) +{ return (uint16_t)0xFFFF; } diff --git a/targets/TARGET_Realtek/TARGET_AMEBA/flash_api.c b/targets/TARGET_Realtek/TARGET_AMEBA/flash_api.c index 344ba2fa7a..790b1c075f 100644 --- a/targets/TARGET_Realtek/TARGET_AMEBA/flash_api.c +++ b/targets/TARGET_Realtek/TARGET_AMEBA/flash_api.c @@ -452,7 +452,6 @@ int flash_burst_write(flash_t *obj, uint32_t address ,uint32_t Length, uint8_t * SpicDisableRtl8195A(); return 1; - } /** * @brief Read a stream of data from specified address @@ -563,7 +562,6 @@ int flash_get_extend_addr(flash_t *obj) SpicDisableRtl8195A(); return Status; - } diff --git a/targets/TARGET_Realtek/TARGET_AMEBA/gpio_api.c b/targets/TARGET_Realtek/TARGET_AMEBA/gpio_api.c index a41226e0d8..d7845c6b7d 100644 --- a/targets/TARGET_Realtek/TARGET_AMEBA/gpio_api.c +++ b/targets/TARGET_Realtek/TARGET_AMEBA/gpio_api.c @@ -103,14 +103,16 @@ void gpio_mode(gpio_t *obj, PinMode mode) } // Initial the Pin direction -void gpio_dir(gpio_t *obj, PinDirection direction) { +void gpio_dir(gpio_t *obj, PinDirection direction) +{ obj->direction = direction; gpio_set_hal_pin_mode(obj); HAL_GPIO_Init(&obj->hal_pin); } // Change the pin direction directly -void gpio_change_dir(gpio_t *obj, PinDirection direction) { +void gpio_change_dir(gpio_t *obj, PinDirection direction) +{ uint32_t reg_value; uint8_t port_num; uint8_t pin_num; @@ -151,7 +153,8 @@ void gpio_write(gpio_t *obj, int value) } } -int gpio_read(gpio_t *obj) { +int gpio_read(gpio_t *obj) +{ volatile uint32_t reg_value; uint8_t port_num; uint8_t pin_num; @@ -191,7 +194,8 @@ void gpio_pull_ctrl(gpio_t *obj, PinMode pull_type) } -void gpio_deinit(gpio_t *obj) { +void gpio_deinit(gpio_t *obj) +{ HAL_GPIO_DeInit(&obj->hal_pin); } diff --git a/targets/TARGET_Realtek/TARGET_AMEBA/i2c_api.c b/targets/TARGET_Realtek/TARGET_AMEBA/i2c_api.c index dfe3b101d9..2e67aa203e 100644 --- a/targets/TARGET_Realtek/TARGET_AMEBA/i2c_api.c +++ b/targets/TARGET_Realtek/TARGET_AMEBA/i2c_api.c @@ -76,8 +76,8 @@ static SAL_I2C_TRANSFER_BUF i2ctxtranbuf[4]; static SAL_I2C_TRANSFER_BUF i2crxtranbuf[4]; extern u32 ConfigDebugErr; extern u32 ConfigDebuginfo; -void i2c_init(i2c_t *obj, PinName sda, PinName scl) { - +void i2c_init(i2c_t *obj, PinName sda, PinName scl) +{ uint32_t i2c_sel; uint32_t i2c_idx; PSAL_I2C_MNGT_ADPT pSalI2CMngtAdpt = NULL; @@ -191,7 +191,8 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) { RtkI2CInitForPS(pSalI2CHND); } -void i2c_frequency(i2c_t *obj, int hz) { +void i2c_frequency(i2c_t *obj, int hz) +{ PSAL_I2C_MNGT_ADPT pSalI2CMngtAdpt = NULL; PSAL_I2C_HND pSalI2CHND = NULL; pSalI2CMngtAdpt = &(obj->SalI2CMngtAdpt); @@ -225,23 +226,23 @@ void i2c_frequency(i2c_t *obj, int hz) { } } -inline int i2c_start(i2c_t *obj) { +inline int i2c_start(i2c_t *obj) +{ address_save_int = 0; Byte_count = 0; memset(address_save, 0, sizeof(address_save)); return 0; } -inline int i2c_stop(i2c_t *obj) { +inline int i2c_stop(i2c_t *obj) +{ return 0; } -extern u32 -HalDelayUs( - IN u32 us -); +extern u32 HalDelayUs(IN u32 us); -int i2c_read(i2c_t *obj, int address, char *data, int length, int stop) { +int i2c_read(i2c_t *obj, int address, char *data, int length, int stop) +{ PSAL_I2C_MNGT_ADPT pSalI2CMngtAdpt = NULL; PSAL_I2C_HND pSalI2CHND = NULL; @@ -308,8 +309,8 @@ int i2c_read(i2c_t *obj, int address, char *data, int length, int stop) { } } -int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop) { - +int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop) +{ PSAL_I2C_MNGT_ADPT pSalI2CMngtAdpt = NULL; PSAL_I2C_HND pSalI2CHND = NULL; u32 I2CInTOTcnt = 0; @@ -373,7 +374,8 @@ int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop) { } } -int i2c_byte_read(i2c_t *obj, int last) { +int i2c_byte_read(i2c_t *obj, int last) +{ uint8_t i2cdatlocal; PSAL_I2C_MNGT_ADPT pSalI2CMngtAdpt = NULL; PSAL_I2C_HND pSalI2CHND = NULL; @@ -396,7 +398,8 @@ int i2c_byte_read(i2c_t *obj, int last) { return (int)i2cdatlocal; } -int i2c_byte_write(i2c_t *obj, int data) { +int i2c_byte_write(i2c_t *obj, int data) +{ if(Byte_count<3){ address_save[Byte_count]=data; Byte_count++; @@ -434,7 +437,8 @@ int i2c_byte_write(i2c_t *obj, int data) { return 1; } -void i2c_reset(i2c_t *obj) { +void i2c_reset(i2c_t *obj) +{ PSAL_I2C_MNGT_ADPT pSalI2CMngtAdpt = NULL; PSAL_I2C_HND pSalI2CHND = NULL; pSalI2CMngtAdpt = &(obj->SalI2CMngtAdpt); @@ -446,7 +450,8 @@ void i2c_reset(i2c_t *obj) { #if DEVICE_I2CSLAVE -void i2c_slave_address(i2c_t *obj, int idx, uint32_t address, uint32_t mask) { +void i2c_slave_address(i2c_t *obj, int idx, uint32_t address, uint32_t mask) +{ PSAL_I2C_MNGT_ADPT pSalI2CMngtAdpt = NULL; PSAL_I2C_HND pSalI2CHND = NULL; pSalI2CMngtAdpt = &(obj->SalI2CMngtAdpt); @@ -463,8 +468,8 @@ void i2c_slave_address(i2c_t *obj, int idx, uint32_t address, uint32_t mask) { } } -void i2c_slave_mode(i2c_t *obj, int enable_slave) { - +void i2c_slave_mode(i2c_t *obj, int enable_slave) +{ PSAL_I2C_MNGT_ADPT pSalI2CMngtAdpt = NULL; PSAL_I2C_HND pSalI2CHND = NULL; pSalI2CMngtAdpt = &(obj->SalI2CMngtAdpt); @@ -491,8 +496,8 @@ void i2c_slave_mode(i2c_t *obj, int enable_slave) { #define WriteGeneral 2 // the master is writing to all slave #define WriteAddressed 3 // the master is writing to this slave (slave = receiver) -int i2c_slave_receive(i2c_t *obj) { - +int i2c_slave_receive(i2c_t *obj) +{ int i2cslvrevsts = NoData; PSAL_I2C_MNGT_ADPT pSalI2CMngtAdpt = NULL; PSAL_I2C_HND pSalI2CHND = NULL; @@ -503,8 +508,8 @@ int i2c_slave_receive(i2c_t *obj) { return i2cslvrevsts; } -int i2c_slave_read(i2c_t *obj, char *data, int length) { - +int i2c_slave_read(i2c_t *obj, char *data, int length) +{ u32 I2CInTOTcnt = 0; u32 InTimeoutCount = 0; u32 InStartCount = 0; @@ -554,7 +559,8 @@ int i2c_slave_read(i2c_t *obj, char *data, int length) { } } -int i2c_slave_write(i2c_t *obj, const char *data, int length) { +int i2c_slave_write(i2c_t *obj, const char *data, int length) +{ PSAL_I2C_MNGT_ADPT pSalI2CMngtAdpt = NULL; PSAL_I2C_HND pSalI2CHND = NULL; pSalI2CMngtAdpt = &(obj->SalI2CMngtAdpt); diff --git a/targets/TARGET_Realtek/TARGET_AMEBA/log_uart_api.c b/targets/TARGET_Realtek/TARGET_AMEBA/log_uart_api.c index e93289818f..9015c81066 100644 --- a/targets/TARGET_Realtek/TARGET_AMEBA/log_uart_api.c +++ b/targets/TARGET_Realtek/TARGET_AMEBA/log_uart_api.c @@ -54,13 +54,11 @@ int32_t log_uart_init (log_uart_t *obj, int baudrate, int data_bits, SerialParit if (log_uart_support_rate[i] == baudrate) { break; } - } - + } if (log_uart_support_rate[i]== 0xFFFFFF) { DBG_UART_ERR("log_uart_init: Not support Baud Rate %d\n", baudrate); return -1; } - // check word width if ((data_bits < 5) || (data_bits > 8)) { DBG_UART_ERR("log_uart_init: Not support Word Width %d\n", data_bits); @@ -150,12 +148,10 @@ void log_uart_baud(log_uart_t *obj, int baudrate) break; } } - if (log_uart_support_rate[i]== 0xFFFFFF) { DBG_UART_ERR("log_uart_baud: Not support Baud Rate %d\n", baudrate); return; } - pUartAdapter->BaudRate = baudrate; HalLogUartSetBaudRate(pUartAdapter); } @@ -163,7 +159,6 @@ void log_uart_baud(log_uart_t *obj, int baudrate) void log_uart_format(log_uart_t *obj, int data_bits, SerialParity parity, int stop_bits) { HAL_LOG_UART_ADAPTER *pUartAdapter; - pUartAdapter = &obj->log_hal_uart; // check word width diff --git a/targets/TARGET_Realtek/TARGET_AMEBA/port_api.c b/targets/TARGET_Realtek/TARGET_AMEBA/port_api.c index adc02cdf72..a181d88c08 100644 --- a/targets/TARGET_Realtek/TARGET_AMEBA/port_api.c +++ b/targets/TARGET_Realtek/TARGET_AMEBA/port_api.c @@ -71,7 +71,8 @@ extern u32 HAL_GPIO_GetPinName(u32 chip_pin); // high nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, ...) // low nibble = pin number -PinName port_pin(PortName port, int pin_n) { +PinName port_pin(PortName port, int pin_n) +{ return (PinName)(pin_n + (port << 4)); } @@ -214,5 +215,5 @@ int port_read(port_t *obj) return value; } -#endif -#endif +#endif //#if DEVICE_PORTIN || DEVICE_PORTOUT +#endif //#if CONFIG_GPIO_EN diff --git a/targets/TARGET_Realtek/TARGET_AMEBA/pwmout_api.c b/targets/TARGET_Realtek/TARGET_AMEBA/pwmout_api.c index b56af0543a..47b55c62e8 100644 --- a/targets/TARGET_Realtek/TARGET_AMEBA/pwmout_api.c +++ b/targets/TARGET_Realtek/TARGET_AMEBA/pwmout_api.c @@ -141,4 +141,4 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us) } #endif // #ifdef CONFIG_PWM_EN -#endif +#endif // #if DEVICE_PWMOUT diff --git a/targets/TARGET_Realtek/TARGET_AMEBA/serial_api.c b/targets/TARGET_Realtek/TARGET_AMEBA/serial_api.c index 80adf8c34b..a6186dec96 100644 --- a/targets/TARGET_Realtek/TARGET_AMEBA/serial_api.c +++ b/targets/TARGET_Realtek/TARGET_AMEBA/serial_api.c @@ -186,7 +186,8 @@ void serial_free(serial_t *obj) #endif } -void serial_baud(serial_t *obj, int baudrate) { +void serial_baud(serial_t *obj, int baudrate) +{ #ifdef CONFIG_MBED_ENABLED if(obj->index == UART_3){ return; @@ -459,5 +460,5 @@ void serial_pinout_tx(PinName tx) #if DEVICE_SERIAL_ASYNCH #endif -#endif +#endif //#if CONFIG_UART_EN diff --git a/tools/targets/REALTEK_RTL8195AM.py b/tools/targets/REALTEK_RTL8195AM.py index 09371b1805..74fb1b2089 100644 --- a/tools/targets/REALTEK_RTL8195AM.py +++ b/tools/targets/REALTEK_RTL8195AM.py @@ -116,7 +116,7 @@ def rtl8195a_elf2bin(toolchain, image_elf, image_bin): # actually it's block img2_sections = ["IMAGE2"] else: - printf("[error] unsupported toolchain") + toolchain + print("[error] unsupported toolchain") + toolchain return ram2_info = {'addr':None, 'size':0} image_name = os.path.splitext(image_elf)[0] @@ -127,18 +127,15 @@ def rtl8195a_elf2bin(toolchain, image_elf, image_bin): old_bin = image_name + '.bin' for section in img2_sections: section_info = parse_section(toolchain, image_elf, section) - #print("addr 0x%x, size 0x%x" % (section_info['addr'], section_info['size'])) if ram2_info['addr'] is None or ram2_info['addr'] > section_info['addr']: ram2_info['addr'] = section_info['addr'] ram2_info['size'] = ram2_info['size'] + section_info['size'] - #print("toolchain = %s, bin name = \"%s, ram2_addr = 0x%x, ram2_size = 0x%x" % (toolchain, old_bin, ram2_info['addr'], ram2_info['size'])) - prepend(old_bin, ram2_prepend_bin, toolchain, ram2_info) # write output file output = open(image_bin, "wb") append_image_file(ram1_prepend_bin, output) append_image_file(ram2_prepend_bin, output) output.close() - #print("post built done") + # post built done