modify code standard from Liu Weichao

it is fit
This commit is contained in:
xuedongliang 2021-04-29 16:47:51 +08:00
commit 5d13421ae8
13 changed files with 75 additions and 94 deletions

View File

@ -107,7 +107,7 @@ void PingEthernet()
printf("ATAdapterFind failed .\n");
printf("Waiting for msg...\n");
struct ping_result result;
struct PingResult result;
char *ip_str = "192.168.250.250";
if (!opened){
@ -131,7 +131,7 @@ void SetUpEthernet()
printf("ATAdapterFind failed .\n");
printf("Waiting for msg...\n");
struct ping_result result;
struct PingResult result;
if (!opened){
opened = true;

View File

@ -103,7 +103,7 @@ void PingWifi()
}
printf("Waiting for msg...\n");
struct ping_result result;
struct PingResult result;
//www.baidu.com
char *ip_str = "36.152.44.95";
@ -123,7 +123,7 @@ void SetUpWifi()
}
printf("Waiting for msg...\n");
struct ping_result result;
struct PingResult result;
at_adapter->parent.done.NetAiitOpen(&at_adapter->parent);

View File

@ -240,7 +240,7 @@ __exit:
return result;
}
int EthernetPing(struct AdapterAT *adapterAT, const char *destination,struct ping_result *ping_resp)
int EthernetPing(struct AdapterAT *adapterAT, const char *destination,struct PingResult *ping_resp)
{
char *ping_result = NONE;
ping_result = (char *) UserCalloc(1, 17);

View File

@ -43,9 +43,9 @@ struct Socket
{
uint8_t fd;
uint8_t status ;
struct ADDRESS_IPV4 src_ip;
struct AddressIpv4 src_ip;
uint16_t src_port;
struct ADDRESS_IPV4 dst_ip;
struct AddressIpv4 dst_ip;
uint16_t dst_port;
uint8_t type;
uint8_t af_type;
@ -59,24 +59,24 @@ struct ATDone
int (*ATOperateUp)(struct AdapterAT *adapterAT);
int (*ATOperateDown)(struct AdapterAT *adapterAT);
int (*ATOperateAddr)(struct AdapterAT *adapterAT, uint ip, uint gateway, uint netmask);
int (*ATOperateDns)(struct AdapterAT *adapterAT, struct ADDRESS_IPV4 *dns_addr, uint8 dns_count);
int (*ATOperateDns)(struct AdapterAT *adapterAT, struct AddressIpv4 *dns_addr, uint8 dns_count);
int (*ATOperateDHCP)(struct AdapterAT *adapterAT, bool enable);
int (*ATPing)(struct AdapterAT *adapterAT, const char *destination, struct ping_result *ping_resp);
int (*ATPing)(struct AdapterAT *adapterAT, const char *destination, struct PingResult *ping_resp);
int (*ATNetstat)(struct AdapterAT *adapterAT);
int (*ATOperateDefault)(struct AdapterAT *adapterAT);
int (*ATSocketCreate)(struct AdapterAT *adapterAT , uint8_t socket_fd , uint8_t type , uint8_t af_type );
int (*ATSocketConnect)(struct AdapterAT *adapterAT , uint8_t socket_fd , struct ADDRESS_IPV4 dst_ip , uint16_t dst_port, uint8 is_client);
int (*ATSocketConnect)(struct AdapterAT *adapterAT , uint8_t socket_fd , struct AddressIpv4 dst_ip , uint16_t dst_port, uint8 is_client);
int (*ATSocketClose)(struct AdapterAT *adapterAT , uint8_t socket_fd );
};
struct AdapterAT {
struct Adapter parent;
struct ATAgent *agent;
struct ADDRESS_IPV4 ip;
struct ADDRESS_IPV4 netmask;
struct ADDRESS_IPV4 gateway;
struct ADDRESS_IPV4 dns[DNS_COUNT];
struct AddressIpv4 ip;
struct AddressIpv4 netmask;
struct AddressIpv4 gateway;
struct AddressIpv4 dns[DNS_COUNT];
uint32 at_adapter_id;
struct Socket socket[SOCKET_MAX];
uint8 hardware_address_len;
@ -84,7 +84,7 @@ struct AdapterAT {
uint16 flags;
uint16 mtu;
void (*change_cb )(struct AdapterAT *adapterAT, enum cb_type type, enum change_type ch_type_);
void (*change_cb )(struct AdapterAT *adapterAT, enum CbType type, enum ChangeType ch_type_);
struct ATDone atdone;

View File

@ -42,7 +42,7 @@ int EthernetReceive(struct Adapter *padapter, char *rev_buffer, int buffer_len,
int EthernetSetUp(struct AdapterAT *adapterAT);
int EthernetDHCP(struct AdapterAT *adapterAT, bool enable);
int EthernetPing(struct AdapterAT *adapterAT, const char *destination, struct ping_result *ping_resp);
int EthernetPing(struct AdapterAT *adapterAT, const char *destination, struct PingResult *ping_resp);
int EthernetNetstat(struct AdapterAT *adapterAT);
#endif

View File

@ -44,7 +44,7 @@ int WifiSetUp(struct AdapterAT *adapter_at);
int WifiSetDown(struct AdapterAT *adapter_at);
int WifiSetAddr(struct AdapterAT *adapter_at, uint ip, uint gateway, uint netmask);
int WifiDHCP(struct AdapterAT *adapter_at, bool enable);
int WifiPing(struct AdapterAT *adapter_at, const char *destination,struct ping_result *ping_resp);
int WifiPing(struct AdapterAT *adapter_at, const char *destination,struct PingResult *ping_resp);
int WifiNetstat(struct AdapterAT *adapter_at);
#endif

View File

@ -31,7 +31,7 @@ typedef void(*send_success)(void* param);
#define DNS_COUNT 2U
#define HW_MAX 8U
enum cb_type
enum CbType
{
CB_ADDR_IP, /* IP address */
CB_ADDR_NETMASK, /* subnet mask */
@ -47,24 +47,24 @@ enum cb_type
CB_STATUS_DHCP_DISABLE, /* disable DHCP capability */
};
enum change_type
enum ChangeType
{
addr_change,
status_change,
ADDR_CHANGE,
STATUS_CHANGE,
};
struct ADDRESS_IPV4
struct AddressIpv4
{
uint32 ipv4;
};
struct ping_result
struct PingResult
{
struct ADDRESS_IPV4 ip_addr; /* response IP address */
struct AddressIpv4 ip_addr; /* response IP address */
uint16 data_len; /* response data length */
uint16 ttl; /* time to live */
uint32 ticks; /* response time, unit tick */
void *UserData; /* user-specific data */
void *user_data; /* user-specific data */
};
#define ETHERNET_ADAPTER_ID 0x03U

View File

@ -304,7 +304,7 @@ __exit:
return result;
}
int WifiPing(struct AdapterAT *adapter_at, const char *destination,struct ping_result *ping_resp)
int WifiPing(struct AdapterAT *adapter_at, const char *destination,struct PingResult *ping_resp)
{
char *ping_result = NONE;
char *dst = NONE;

View File

@ -36,25 +36,6 @@
extern "C" {
#endif
enum dev
{
Dev_TYPE_Block,
Dev_TYPE_Char ,
Dev_TYPE_CAN ,
Dev_TYPE_Graphic,
Dev_TYPE_I2CBUS,
Dev_TYPE_Miscellaneous,
Dev_TYPE_NetIf ,
Dev_TYPE_RTC ,
Dev_TYPE_SPIBUS,
Dev_TYPE_SPIDevice,
Dev_TYPE_Timer,
Dev_TYPE_Touch,
Dev_TYPE_USBDevice,
Dev_TYPE_USBHost,
Dev_TYPE_Unknown
};
#define OSIGN_OPER_CLOSE (0U << 0)
#define OSIGN_OPER_RDONLY (1U << 0)
#define OSIGN_OPER_WRONLY (1U << 1)

View File

@ -453,7 +453,7 @@ static struct DynamicBuddyMemoryDone DynamicDone = {
/**
* This function initializes the static segment struction.
*
* @param StaticSegment the StaticSegment to be initialized
* @param static_segment the static_segment to be initialized
*/
static void SmallMemInit(struct ByteMemory *byte_memory)
{
@ -520,28 +520,28 @@ static void SmallMemInit(struct ByteMemory *byte_memory)
*/
static void SmallMemFree(void *pointer)
{
struct segment *StaticSegment = NONE;
struct segment *static_segment = NONE;
struct DynamicAllocNode *node = NONE;
NULL_PARAM_CHECK(pointer);
/* get the allocNode */
node = PTR2ALLOCNODE((char*)pointer-SIZEOF_DYNAMICALLOCNODE_MEM);
StaticSegment = (struct segment*)(x_size_t)node->size;
static_segment = (struct segment*)(x_size_t)node->size;
/* update the statistic information of StaticSegment */
node->size = (x_size_t)StaticSegment->freelist;
StaticSegment->freelist = (uint8 *)node;
StaticSegment->block_free_count++;
/* update the statistic information of static_segment */
node->size = (x_size_t)static_segment->freelist;
static_segment->freelist = (uint8 *)node;
static_segment->block_free_count++;
/* parameter detection */
CHECK(StaticSegment->block_free_count <= StaticSegment->block_total_count);
CHECK(static_segment->block_free_count <= static_segment->block_total_count);
}
/**
* This funcation allocates a static memory block from static segment.
*
* @param StaticSegment the heart static segment structure to allocate static memory
* @param static_segment the heart static segment structure to allocate static memory
* @param size the size to be allocated
*
* @return pointer address on success; NULL on failure
@ -550,26 +550,26 @@ static void *SmallMemMalloc(struct ByteMemory *byte_memory, x_size_t size)
{
void *result = NONE;
struct DynamicAllocNode *node = NONE;
struct segment *StaticSegment = NONE;
struct segment *static_segment = NONE;
NULL_PARAM_CHECK(byte_memory);
if (size == SIZEOF_32B)
StaticSegment = &byte_memory->static_manager[0];
static_segment = &byte_memory->static_manager[0];
else
StaticSegment = &byte_memory->static_manager[1];
static_segment = &byte_memory->static_manager[1];
/* current static segment has free static memory block */
if(StaticSegment->block_free_count>0) {
if(static_segment->block_free_count>0) {
/* get the head static memory block */
result = StaticSegment->freelist;
node = PTR2ALLOCNODE(StaticSegment->freelist);
result = static_segment->freelist;
node = PTR2ALLOCNODE(static_segment->freelist);
node->prev_adj_size = STATIC_BLOCK_MASK;
/* update the statistic information of static segment */
StaticSegment->freelist = (uint8 *)(long)(node->size);
StaticSegment->block_free_count--;
node->size = (long)StaticSegment;
static_segment->freelist = (uint8 *)(long)(node->size);
static_segment->block_free_count--;
node->size = (long)static_segment;
}
if(result) {
@ -727,7 +727,7 @@ void x_free(void *pointer)
node = PTR2ALLOCNODE((char*)pointer-SIZEOF_DYNAMICALLOCNODE_MEM);
CHECK(ByteManager.done->JudgeAllocated(node));
/* judge release the memory block ro StaticSegment or dynamic buddy memory */
/* judge release the memory block ro static_segment or dynamic buddy memory */
#ifdef KERNEL_SMALL_MEM_ALLOC
if(node->prev_adj_size & STATIC_BLOCK_MASK) {
ByteManager.static_manager->done->release(pointer);

View File

@ -50,15 +50,15 @@ int32 JudgeAssignReadyBitmapIsEmpty(struct OsAssignReadyVector *ready_vector)
struct TaskDescriptor * ChooseTaskWithHighestPrio(struct OsAssignReadyVector *ready_vector)
{
struct TaskDescriptor *TargetTask = NONE;
struct TaskDescriptor *target_task = NONE;
NULL_PARAM_CHECK(ready_vector);
TargetTask = SYS_DOUBLE_LINKLIST_ENTRY(ready_vector->priority_ready_vector[ready_vector->highest_prio].node_next,
target_task = SYS_DOUBLE_LINKLIST_ENTRY(ready_vector->priority_ready_vector[ready_vector->highest_prio].node_next,
struct TaskDescriptor,
task_dync_sched_member.sched_link);
return TargetTask;
return target_task;
}
void OsAssignReadyVectorInit(struct OsAssignReadyVector *ready_vector)

View File

@ -67,11 +67,11 @@ typedef enum
typedef enum
{
SD_Respone_1 = 1,
SD_Respone_1b,
SD_Respone_2,
SD_Respone_3,
SD_Respone_7,
SD_RESPONE_1 = 1,
SD_RESPONE_1B,
SD_RESPONE_2,
SD_RESPONE_3,
SD_RESPONE_7,
}SdRespone;
struct SdCmdParam

View File

@ -102,10 +102,10 @@ static uint32 SdSendCmdByte(SpiSdDeviceType spi_sd_dev, struct SdCmdParam *sd_cm
switch (sd_cmd_param->sd_respone_type)
{
case SD_Respone_1 :
case SD_RESPONE_1 :
sd_cmd_param->sd_respone_data[0] = read[0];
return EOK;
case SD_Respone_1b :
case SD_RESPONE_1B :
sd_cmd_param->sd_respone_data[0] = read[0];
start_time = 0;
@ -119,7 +119,7 @@ static uint32 SdSendCmdByte(SpiSdDeviceType spi_sd_dev, struct SdCmdParam *sd_cm
}while(0xFF != read_byte);
return EOK;
case SD_Respone_2 :
case SD_RESPONE_2 :
sd_cmd_param->sd_respone_data[0] = read[0];
read_param.buffer = (void *)&read_byte;
@ -129,8 +129,8 @@ static uint32 SdSendCmdByte(SpiSdDeviceType spi_sd_dev, struct SdCmdParam *sd_cm
sd_cmd_param->sd_respone_data[1] = read_byte;
return EOK;
case SD_Respone_3 :
case SD_Respone_7 :
case SD_RESPONE_3 :
case SD_RESPONE_7 :
sd_cmd_param->sd_respone_data[0] = read[0];
read_param.buffer = (void *)&read;
@ -204,7 +204,7 @@ static uint32 SdHwInit(SpiSdDeviceType spi_sd_dev)
g_sd_cmd_param.sd_cmd_type = SD_CMD_0;
g_sd_cmd_param.sd_cmd_args = 0x00;
g_sd_cmd_param.sd_cmd_crc = 0x95;
g_sd_cmd_param.sd_respone_type = SD_Respone_1;
g_sd_cmd_param.sd_respone_type = SD_RESPONE_1;
start_time = 0;
@ -238,7 +238,7 @@ static uint32 SdConfirmType(SpiSdDeviceType spi_sd_dev)
g_sd_cmd_param.sd_cmd_type = SD_CMD_8;
g_sd_cmd_param.sd_cmd_args = 0x01AA;
g_sd_cmd_param.sd_cmd_crc = 0x87;
g_sd_cmd_param.sd_respone_type = SD_Respone_7;
g_sd_cmd_param.sd_respone_type = SD_RESPONE_7;
start_time = 0;
@ -290,7 +290,7 @@ static uint32 SdHwReset(SpiSdDeviceType spi_sd_dev)
g_sd_cmd_param.sd_cmd_type = SD_CMD_55;
g_sd_cmd_param.sd_cmd_args = 0x00;
g_sd_cmd_param.sd_cmd_crc = 0x65;
g_sd_cmd_param.sd_respone_type = SD_Respone_1;
g_sd_cmd_param.sd_respone_type = SD_RESPONE_1;
/*pull down the cs pin*/
SpiDevConfigureCs(&spi_sd_dev->spi_dev->haldev, 1, 0);
@ -308,7 +308,7 @@ static uint32 SdHwReset(SpiSdDeviceType spi_sd_dev)
g_sd_cmd_param.sd_cmd_type = SD_ACMD_41;
g_sd_cmd_param.sd_cmd_args = 0x40000000;
g_sd_cmd_param.sd_cmd_crc = 0x77;
g_sd_cmd_param.sd_respone_type = SD_Respone_1;
g_sd_cmd_param.sd_respone_type = SD_RESPONE_1;
ret = SdSendCmdByte(spi_sd_dev, &g_sd_cmd_param);
if (EOK != ret) {
@ -325,7 +325,7 @@ static uint32 SdHwReset(SpiSdDeviceType spi_sd_dev)
g_sd_cmd_param.sd_cmd_type = SD_CMD_58;
g_sd_cmd_param.sd_cmd_args = 0x00;
g_sd_cmd_param.sd_cmd_crc = 0x00;
g_sd_cmd_param.sd_respone_type = SD_Respone_3;
g_sd_cmd_param.sd_respone_type = SD_RESPONE_3;
/*pull down the cs pin*/
SpiDevConfigureCs(&spi_sd_dev->spi_dev->haldev, 1, 0);
@ -362,7 +362,7 @@ static uint32 SdHwReset(SpiSdDeviceType spi_sd_dev)
g_sd_cmd_param.sd_cmd_type = SD_CMD_55;
g_sd_cmd_param.sd_cmd_args = 0x00;
g_sd_cmd_param.sd_cmd_crc = 0x65;
g_sd_cmd_param.sd_respone_type = SD_Respone_1;
g_sd_cmd_param.sd_respone_type = SD_RESPONE_1;
/*pull down the cs pin*/
SpiDevConfigureCs(&spi_sd_dev->spi_dev->haldev, 1, 0);
@ -381,7 +381,7 @@ static uint32 SdHwReset(SpiSdDeviceType spi_sd_dev)
g_sd_cmd_param.sd_cmd_type = SD_ACMD_41;
g_sd_cmd_param.sd_cmd_args = 0x40000000;
g_sd_cmd_param.sd_cmd_crc = 0x77;
g_sd_cmd_param.sd_respone_type = SD_Respone_1;
g_sd_cmd_param.sd_respone_type = SD_RESPONE_1;
ret = SdSendCmdByte(spi_sd_dev, &g_sd_cmd_param);
if (EOK != ret) {
@ -417,7 +417,7 @@ static uint32 SdHwReset(SpiSdDeviceType spi_sd_dev)
g_sd_cmd_param.sd_cmd_type = SD_CMD_1;
g_sd_cmd_param.sd_cmd_args = 0x00;
g_sd_cmd_param.sd_cmd_crc = 0x00;
g_sd_cmd_param.sd_respone_type = SD_Respone_1;
g_sd_cmd_param.sd_respone_type = SD_RESPONE_1;
/*pull down the cs pin*/
SpiDevConfigureCs(&spi_sd_dev->spi_dev->haldev, 1, 0);
@ -452,7 +452,7 @@ static uint32 SdHwSetBlockLength(SpiSdDeviceType spi_sd_dev)
g_sd_cmd_param.sd_cmd_type = SD_CMD_16;
g_sd_cmd_param.sd_cmd_args = SD_BLOCK_LENGTH;
g_sd_cmd_param.sd_cmd_crc = 0x00;
g_sd_cmd_param.sd_respone_type = SD_Respone_1;
g_sd_cmd_param.sd_respone_type = SD_RESPONE_1;
/*pull down the cs pin*/
SpiDevConfigureCs(&spi_sd_dev->spi_dev->haldev, 1, 0);
@ -674,7 +674,7 @@ static uint32 SdHwReadCSD(SpiSdDeviceType spi_sd_dev)
g_sd_cmd_param.sd_cmd_type = SD_CMD_9;
g_sd_cmd_param.sd_cmd_args = 0x00;
g_sd_cmd_param.sd_cmd_crc = 0x00;
g_sd_cmd_param.sd_respone_type = SD_Respone_2;
g_sd_cmd_param.sd_respone_type = SD_RESPONE_2;
/*pull down the cs pin*/
SpiDevConfigureCs(&spi_sd_dev->spi_dev->haldev, 1, 0);
@ -754,7 +754,7 @@ static uint32 SdReadSingleBlock(SpiSdDeviceType spi_sd_dev, uint32 id, uint8 *re
g_sd_cmd_param.sd_cmd_args = id * spi_sd_dev->sd_param.block_param.block_size;
}
g_sd_cmd_param.sd_cmd_crc = 0x00;
g_sd_cmd_param.sd_respone_type = SD_Respone_1;
g_sd_cmd_param.sd_respone_type = SD_RESPONE_1;
/*pull down the cs pin*/
SpiDevConfigureCs(&spi_sd_dev->spi_dev->haldev, 1, 0);
@ -823,7 +823,7 @@ static uint32 SdReadMultiBlock(SpiSdDeviceType spi_sd_dev, uint32 id, const uint
g_sd_cmd_param.sd_cmd_args = id * spi_sd_dev->sd_param.block_param.block_size;
}
g_sd_cmd_param.sd_cmd_crc = 0x00;
g_sd_cmd_param.sd_respone_type = SD_Respone_1;
g_sd_cmd_param.sd_respone_type = SD_RESPONE_1;
/*pull down the cs pin*/
SpiDevConfigureCs(&spi_sd_dev->spi_dev->haldev, 1, 0);
@ -876,7 +876,7 @@ static uint32 SdReadMultiBlock(SpiSdDeviceType spi_sd_dev, uint32 id, const uint
g_sd_cmd_param.sd_cmd_type = SD_CMD_12;
g_sd_cmd_param.sd_cmd_args = 0x00;
g_sd_cmd_param.sd_cmd_crc = 0x00;
g_sd_cmd_param.sd_respone_type = SD_Respone_1b;
g_sd_cmd_param.sd_respone_type = SD_RESPONE_1B;
ret = SdSendCmdByte(spi_sd_dev, &g_sd_cmd_param);
if (EOK != ret) {
@ -908,7 +908,7 @@ static uint32 SdWriteSingleBlock(SpiSdDeviceType spi_sd_dev, uint32 id, const ui
g_sd_cmd_param.sd_cmd_args = id * spi_sd_dev->sd_param.block_param.block_size;
}
g_sd_cmd_param.sd_cmd_crc = 0x00;
g_sd_cmd_param.sd_respone_type = SD_Respone_1;
g_sd_cmd_param.sd_respone_type = SD_RESPONE_1;
/*pull down the cs pin*/
SpiDevConfigureCs(&spi_sd_dev->spi_dev->haldev, 1, 0);
@ -986,7 +986,7 @@ static uint32 SdWriteMultiBlock(SpiSdDeviceType spi_sd_dev, uint32 id, const voi
g_sd_cmd_param.sd_cmd_type = SD_CMD_55;
g_sd_cmd_param.sd_cmd_args = 0x00;
g_sd_cmd_param.sd_cmd_crc = 0x00;
g_sd_cmd_param.sd_respone_type = SD_Respone_1;
g_sd_cmd_param.sd_respone_type = SD_RESPONE_1;
ret = SdSendCmdByte(spi_sd_dev, &g_sd_cmd_param);
if (EOK != ret) {
@ -1002,7 +1002,7 @@ static uint32 SdWriteMultiBlock(SpiSdDeviceType spi_sd_dev, uint32 id, const voi
g_sd_cmd_param.sd_cmd_type = SD_ACMD_23;
g_sd_cmd_param.sd_cmd_args = block_num;
g_sd_cmd_param.sd_cmd_crc = 0x00;
g_sd_cmd_param.sd_respone_type = SD_Respone_1;
g_sd_cmd_param.sd_respone_type = SD_RESPONE_1;
ret = SdSendCmdByte(spi_sd_dev, &g_sd_cmd_param);
if (EOK != ret) {
@ -1023,7 +1023,7 @@ static uint32 SdWriteMultiBlock(SpiSdDeviceType spi_sd_dev, uint32 id, const voi
g_sd_cmd_param.sd_cmd_args = id * spi_sd_dev->sd_param.block_param.block_size;
}
g_sd_cmd_param.sd_cmd_crc = 0x00;
g_sd_cmd_param.sd_respone_type = SD_Respone_1;
g_sd_cmd_param.sd_respone_type = SD_RESPONE_1;
start_time = 0;
do