mirror of https://github.com/ARMmbed/mbed-os.git
improve coding style
parent
005ce58f44
commit
0c046a4c38
|
@ -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;
|
||||
|
@ -72,7 +72,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);
|
||||
pSalADCMngtAdpt->pIrqHnd = &(obj->ADCIrqHandleDat);
|
||||
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -55,12 +55,10 @@ int32_t log_uart_init (log_uart_t *obj, int baudrate, int data_bits, SerialParit
|
|||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -141,4 +141,4 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us)
|
|||
}
|
||||
|
||||
#endif // #ifdef CONFIG_PWM_EN
|
||||
#endif
|
||||
#endif // #if DEVICE_PWMOUT
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue