Compare commits
29 Commits
3fe85dc7db
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e577da707 | |||
| dccfedc74c | |||
| 8b94eb2eff | |||
| 2db1937c89 | |||
| 30c9ee1f76 | |||
| 5f7b200854 | |||
| 94222071e9 | |||
| f7b52d9d2e | |||
| b88aaf47e5 | |||
| af031e23d8 | |||
| dc874bf6f1 | |||
| 336d1bc100 | |||
| be37b5d206 | |||
| 296d02ff4a | |||
| 5d56543f64 | |||
| 7facae7a1a | |||
| 770247f9b6 | |||
| 61a92c8620 | |||
| a94db790a6 | |||
| 1166f71883 | |||
| 047a907eac | |||
| cb87de5508 | |||
| 0f45c981a6 | |||
| 2b5ea8434e | |||
| 57e132c535 | |||
| 3605e98cec | |||
| 7f8e108170 | |||
| b155d3ce14 | |||
| a086ce17e4 |
@@ -65,10 +65,9 @@
|
||||
"libList": [
|
||||
"libraries/zf_device"
|
||||
],
|
||||
"sourceDirList": [],
|
||||
"defineList": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"version": "3.3"
|
||||
"version": "3.4"
|
||||
}
|
||||
@@ -7,8 +7,8 @@
|
||||
#include "lwrb.h"
|
||||
#include "crc16.h"
|
||||
|
||||
uint8_t frame_buffer_recv[(2 * (4 + BY_FRAME_DATA_NUM * sizeof(uint32_t))) + 1];
|
||||
uint8_t frame_buffer_send[4 + BY_FRAME_DATA_NUM * sizeof(uint32_t)];
|
||||
uint8_t frame_buffer_recv[(2 * (4 + BY_FRAME_DATA_NUM_RECV * sizeof(uint32_t))) + 1];
|
||||
uint8_t frame_buffer_send[4 + BY_FRAME_DATA_NUM_SEND * sizeof(uint32_t)];
|
||||
uint8_t frame_parse_busy;
|
||||
lwrb_t lwrb_ctx;
|
||||
|
||||
@@ -19,10 +19,10 @@ void by_frame_init(void)
|
||||
uart_rx_interrupt(BY_FRAME_UART_INDEX, ENABLE);
|
||||
}
|
||||
|
||||
void by_frame_send(uint32_t *data_array)
|
||||
void by_frame_send(uint32_t* data_array)
|
||||
{
|
||||
uint16_t crc_cal = 0;
|
||||
const uint8_t data_byte_num = BY_FRAME_DATA_NUM * sizeof(uint32_t);
|
||||
const uint8_t data_byte_num = BY_FRAME_DATA_NUM_SEND * sizeof(uint32_t);
|
||||
|
||||
frame_buffer_send[0] = BY_FRAME_HEAD_1;
|
||||
frame_buffer_send[1] = BY_FRAME_HEAD_2;
|
||||
@@ -49,9 +49,9 @@ void by_frame_parse(uint32_t *data_array)
|
||||
uint32_t len = lwrb_get_full(&lwrb_ctx); // 缓冲区大小
|
||||
uint8_t status = 0; // 状态 0-未找到帧头 1-找到帧头 2-校验
|
||||
uint16_t frame_start = 0; // 帧起始位置
|
||||
uint8_t frame_buf[4 + BY_FRAME_DATA_NUM * sizeof(uint32_t)] = {0}; // 帧
|
||||
uint8_t buf[(4 + BY_FRAME_DATA_NUM * sizeof(uint32_t)) * 2] = {0}; // 用于解析的数据块
|
||||
const uint8_t data_byte_num = BY_FRAME_DATA_NUM * sizeof(uint32_t);
|
||||
uint8_t frame_buf[4 + BY_FRAME_DATA_NUM_RECV * sizeof(uint32_t)] = {0}; // 帧
|
||||
uint8_t buf[(4 + BY_FRAME_DATA_NUM_RECV * sizeof(uint32_t)) * 2] = {0}; // 用于解析的数据块
|
||||
const uint8_t data_byte_num = BY_FRAME_DATA_NUM_RECV * sizeof(uint32_t);
|
||||
|
||||
if (len < 2 * (4 + data_byte_num)) {
|
||||
// 当前要求缓冲区满
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
#define BY_FRAME_UART_INDEX (UART_2)
|
||||
#define BY_FRAME_UART_BAUDRATE (115200)
|
||||
|
||||
#define BY_FRAME_DATA_NUM (3)
|
||||
#define BY_FRAME_DATA_NUM_SEND (3)
|
||||
#define BY_FRAME_DATA_NUM_RECV (1)
|
||||
|
||||
extern void by_frame_init(void);
|
||||
void by_frame_send(uint32_t *data_array);
|
||||
void by_frame_parse(uint32_t *data_array);
|
||||
extern void by_frame_parse_uart_handle(uint8_t data);
|
||||
|
||||
|
||||
#endif
|
||||
247
app/gl_barrier.c
247
app/gl_barrier.c
@@ -2,7 +2,15 @@
|
||||
#include "gl_headfile.h"
|
||||
|
||||
enum barrier_type_e barrier_type = BARRIER_NONE;
|
||||
uint16 time_barrier;
|
||||
enum s_type_e s_type = S_NONE;
|
||||
enum shield_type_e shield_type = SHIELD_NONE;
|
||||
float (*mid_track_s)[2];
|
||||
int32_t mid_track_count_s;
|
||||
int temp_min_s;
|
||||
int temp_max_s;
|
||||
int barrier_begin_flag = 0;
|
||||
int barrier_count = 0;
|
||||
float barrirer_time=500.f;
|
||||
void CheckBarrier()
|
||||
{
|
||||
if (barrier_type == BARRIER_NONE && Lpt0_found_barrier_in && !Lpt1_found_barrier_in && is_straight1) {
|
||||
@@ -15,49 +23,222 @@ void CheckBarrier()
|
||||
|
||||
void RunBarrier()
|
||||
{
|
||||
if (barrier_type == BARRIER_LEFT_BEGIN) {
|
||||
if (barrier_type == BARRIER_LEFT_BEGIN || barrier_type == BARRIER_LEFT_RUNNING) {
|
||||
track_type = TRACK_RIGHT;
|
||||
if (Lpt0_found) {
|
||||
Lpt0_found_count++;
|
||||
}
|
||||
if (Lpt0_found_count >= 1) {
|
||||
Lpt0_found_count = 0;
|
||||
if (barrier_type == BARRIER_LEFT_BEGIN)
|
||||
{
|
||||
timer_clear(TIM_2);
|
||||
timer_start(TIM_2);
|
||||
barrier_type = BARRIER_LEFT_RUNNING;
|
||||
track_type = TRACK_RIGHT;
|
||||
timer_clear(TIM_3);
|
||||
timer_start(TIM_3);
|
||||
}
|
||||
} else if (barrier_type == BARRIER_LEFT_RUNNING) {
|
||||
track_type = TRACK_RIGHT;
|
||||
time_barrier = timer_get(TIM_3);
|
||||
if (time_barrier >= 250) {
|
||||
if (barrier_type == BARRIER_LEFT_RUNNING)
|
||||
{
|
||||
if (timer_get(TIM_2) >= barrirer_time)
|
||||
{
|
||||
barrier_type = BARRIER_NONE;
|
||||
track_type = TRACK_RIGHT;
|
||||
timer_start(TIM_3);
|
||||
timer_clear(TIM_3);
|
||||
timer_stop(TIM_2);
|
||||
timer_clear(TIM_2);
|
||||
}
|
||||
else{
|
||||
barrier_type = BARRIER_LEFT_RUNNING;
|
||||
}
|
||||
}
|
||||
|
||||
if (barrier_type == BARRIER_RIGHT_BEGIN) {
|
||||
track_type = TRACK_LEFT;
|
||||
if (Lpt1_found) {
|
||||
Lpt1_found_count++;
|
||||
|
||||
// if (barrier_begin_flag == 0) {
|
||||
// timer_clear(TIM_3);
|
||||
// timer_start(TIM_3);
|
||||
// barrier_begin_flag = 1;
|
||||
// }
|
||||
// }
|
||||
// if (barrier_type == BARRIER_LEFT_BEGIN || barrier_type == BARRIER_LEFT_RUNNING) {
|
||||
// if (barrier_begin_flag == 1) {
|
||||
// barrier_type = BARRIER_LEFT_BEGIN;
|
||||
// time_barrier = timer_get(TIM_3);
|
||||
// if (time_barrier >= 300 && time_barrier < 600) {
|
||||
// barrier_type = BARRIER_LEFT_RUNNING;
|
||||
// } else if (time_barrier >= 600) {
|
||||
// barrier_type = BARRIER_NONE;
|
||||
// barrier_count = 1;
|
||||
// barrier_begin_flag = 0;
|
||||
// timer_stop(TIM_3);
|
||||
// timer_clear(TIM_3);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (pts_resample_left_count >= 5) {
|
||||
// if (Lpt0_found) {
|
||||
// Lpt0_found_count++;
|
||||
// }
|
||||
// if (Lpt0_found_count >= 1 && barrier_type == BARRIER_LEFT_BEGIN) {
|
||||
// Lpt0_found_count = 0;
|
||||
// barrier_type = BARRIER_LEFT_RUNNING;
|
||||
// track_type = TRACK_RIGHT;
|
||||
// timer_clear(TIM_2);
|
||||
// timer_start(TIM_2);
|
||||
// } else if (barrier_type == BARRIER_LEFT_RUNNING) {
|
||||
// track_type = TRACK_RIGHT;
|
||||
// if (timer_get(TIM_2) >= 500) {
|
||||
// barrier_type = BARRIER_NONE;
|
||||
// track_type = TRACK_RIGHT;
|
||||
// timer_stop(TIM_2);
|
||||
// timer_clear(TIM_2);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// track_type = TRACK_RIGHT;
|
||||
// barrier_type = BARRIER_NONE;
|
||||
// }
|
||||
|
||||
// if (barrier_type == BARRIER_LEFT_RUNNING) {
|
||||
// if (pts_resample_left_count >= 5 && pts_resample_right_count >= 5) {
|
||||
// barrier_type = BARRIER_NONE;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (Lpt0_found) {
|
||||
// Lpt0_found_count++;
|
||||
// }
|
||||
// if (Lpt0_found_count >= 1 && barrier_type == BARRIER_LEFT_BEGIN) {
|
||||
// Lpt0_found_count = 0;
|
||||
// barrier_type = BARRIER_LEFT_RUNNING;
|
||||
// track_type = TRACK_RIGHT;
|
||||
// timer_clear(TIM_2);
|
||||
// timer_start(TIM_2);
|
||||
// } else if (barrier_type == BARRIER_LEFT_RUNNING) {
|
||||
// track_type = TRACK_RIGHT;
|
||||
// if (timer_get(TIM_2) >= 500) {
|
||||
// barrier_type = BARRIER_NONE;
|
||||
// track_type = TRACK_RIGHT;
|
||||
// timer_stop(TIM_2);
|
||||
// timer_clear(TIM_2);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
if (Lpt1_found_count >= 1) {
|
||||
Lpt1_found_count = 0;
|
||||
|
||||
if (barrier_type == BARRIER_RIGHT_BEGIN || barrier_type == BARRIER_RIGHT_RUNNING) {
|
||||
track_type = TRACK_LEFT;
|
||||
if (barrier_type == BARRIER_RIGHT_BEGIN)
|
||||
{
|
||||
timer_clear(TIM_2);
|
||||
timer_start(TIM_2);
|
||||
barrier_type = BARRIER_RIGHT_RUNNING;
|
||||
track_type = TRACK_LEFT;
|
||||
timer_clear(TIM_3);
|
||||
timer_start(TIM_3);
|
||||
}
|
||||
} else if (barrier_type == BARRIER_RIGHT_RUNNING) {
|
||||
track_type = TRACK_LEFT;
|
||||
time_barrier = timer_get(TIM_3);
|
||||
if (time_barrier >= 250) {
|
||||
timer_start(TIM_3);
|
||||
timer_clear(TIM_3);
|
||||
if (barrier_type == BARRIER_RIGHT_RUNNING)
|
||||
{
|
||||
if (timer_get(TIM_2) >= barrirer_time)
|
||||
{
|
||||
barrier_type = BARRIER_NONE;
|
||||
track_type = TRACK_LEFT;
|
||||
timer_stop(TIM_2);
|
||||
timer_clear(TIM_2);
|
||||
}
|
||||
else{
|
||||
barrier_type = BARRIER_RIGHT_RUNNING;
|
||||
}
|
||||
}
|
||||
// if (barrier_begin_flag == 0) {
|
||||
// timer_clear(TIM_3);
|
||||
// timer_start(TIM_3);
|
||||
// barrier_begin_flag = 1;
|
||||
// }
|
||||
// }
|
||||
// if (barrier_type == BARRIER_RIGHT_BEGIN || barrier_type == BARRIER_RIGHT_RUNNING) {
|
||||
// if (barrier_begin_flag == 1) {
|
||||
// barrier_type = BARRIER_RIGHT_BEGIN;
|
||||
// time_barrier = timer_get(TIM_3);
|
||||
// if (time_barrier >= 300 && time_barrier < 600) {
|
||||
// barrier_type = BARRIER_RIGHT_RUNNING;
|
||||
// } else if (time_barrier >= 600) {
|
||||
// barrier_type = BARRIER_NONE;
|
||||
// barrier_count = 1;
|
||||
// barrier_begin_flag = 0;
|
||||
// timer_stop(TIM_3);
|
||||
// timer_clear(TIM_3);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (pts_resample_right_count >= 5) {
|
||||
// if (Lpt1_found) {
|
||||
// Lpt1_found_count++;
|
||||
// }
|
||||
// if (Lpt1_found_count >= 1 && barrier_type == BARRIER_RIGHT_BEGIN) {
|
||||
// Lpt1_found_count = 0;
|
||||
// barrier_type = BARRIER_RIGHT_RUNNING;
|
||||
// track_type = TRACK_LEFT;
|
||||
// timer_clear(TIM_2);
|
||||
// timer_start(TIM_2);
|
||||
// } else if (barrier_type == BARRIER_RIGHT_RUNNING) {
|
||||
// track_type = TRACK_LEFT;
|
||||
// if (timer_get(TIM_2) >= 500) {
|
||||
// timer_stop(TIM_2);
|
||||
// timer_clear(TIM_2);
|
||||
// barrier_type = BARRIER_NONE;
|
||||
// track_type = TRACK_LEFT;
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// track_type = TRACK_LEFT;
|
||||
// barrier_type = BARRIER_NONE;
|
||||
// }
|
||||
|
||||
// if (barrier_type == BARRIER_RIGHT_RUNNING) {
|
||||
// if (pts_resample_left_count >= 5 && pts_resample_right_count >= 5) {
|
||||
// barrier_type = BARRIER_NONE;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
void Check_s()
|
||||
{
|
||||
if (track_type == TRACK_LEFT) {
|
||||
mid_track_s = mid_left;
|
||||
mid_track_count_s = mid_left_count;
|
||||
} else {
|
||||
mid_track_s = mid_right;
|
||||
mid_track_count_s = mid_right_count;
|
||||
}
|
||||
|
||||
int min_s = 1000;
|
||||
int max_s = 1;
|
||||
|
||||
for (int i = 0; i < mid_track_count_s; i++) {
|
||||
if (mid_track_s[i][1] < min_s) {
|
||||
min_s = mid_track_s[i][1];
|
||||
temp_min_s = min_s;
|
||||
}
|
||||
if (mid_track_s[i][1] > max_s) {
|
||||
max_s = mid_track_s[i][1];
|
||||
temp_max_s = max_s;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_straight0 == false && is_straight1 == false && (max_s - min_s) <= 30 && (max_s - min_s) >= 5) {
|
||||
s_type = S_BEGIN;
|
||||
}
|
||||
}
|
||||
|
||||
void RunS()
|
||||
{
|
||||
|
||||
if (temp_max_s - temp_min_s > 30 || (is_straight0 && is_straight1)) {
|
||||
s_type = S_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
// void Check_shield(){
|
||||
// if (begin_flag == 1)
|
||||
// {
|
||||
// shield_type = SHIELD_BEGIN;
|
||||
// timer_clear(TIM_3);
|
||||
// timer_start(TIM_3);
|
||||
// begin_flag = 0;
|
||||
// }
|
||||
// if (timer_get(TIM_3) > 1000 && shield_type == SHIELD_BEGIN)
|
||||
// {
|
||||
// shield_type = SHIELD_NONE;
|
||||
// timer_stop(TIM_3);
|
||||
// timer_clear(TIM_3);
|
||||
// }
|
||||
|
||||
// }
|
||||
@@ -10,11 +10,31 @@ enum barrier_type_e {
|
||||
BARRIER_LEFT_OUT,
|
||||
BARRIER_RIGHT_OUT,
|
||||
};
|
||||
extern uint16 time_barrier;
|
||||
extern enum barrier_type_e barrier_type;
|
||||
|
||||
enum s_type_e {
|
||||
S_NONE,
|
||||
S_BEGIN,
|
||||
S_RUNNING,
|
||||
S_OUT,
|
||||
};
|
||||
|
||||
enum shield_type_e {
|
||||
SHIELD_NONE,
|
||||
SHIELD_BEGIN,
|
||||
};
|
||||
|
||||
extern enum barrier_type_e barrier_type;
|
||||
extern enum s_type_e s_type;
|
||||
extern enum shield_type_e shield_type;
|
||||
extern float (*mid_track_s)[2];
|
||||
extern int32_t mid_track_count_s;
|
||||
extern int temp_min_s;
|
||||
extern int temp_max_s;
|
||||
extern float barrirer_time;
|
||||
void CheckBarrier(void);
|
||||
void Check_s(void);
|
||||
void RunBarrier(void);
|
||||
void Check_shield(void);
|
||||
|
||||
|
||||
#endif /* COMMON_H_ */
|
||||
@@ -15,6 +15,8 @@ int32_t Right_Border_ToLeft_Circle = 0;
|
||||
int32_t Left_Border_ToRight_Circle = 0;
|
||||
int32_t Right_Border_ToRight_Circle = 0;
|
||||
|
||||
int32_t ceshi = 0;
|
||||
|
||||
void CheckCircle()
|
||||
{
|
||||
// 非圆环模式下,单边L角点, 单边长直道
|
||||
@@ -59,7 +61,7 @@ void RunCircle()
|
||||
}
|
||||
} else if (circle_type == CIRCLE_LEFT_RUNNING) // 正常巡线,寻外圆右线
|
||||
{
|
||||
//track_type = TRACK_RIGHT;
|
||||
// track_type = TRACK_RIGHT;
|
||||
track_type = TRACK_LEFT; // 看看加一个如果丢线才切换
|
||||
if (Lpt1_found) {
|
||||
pts_resample_right_count = mid_right_count = Lpt1_rpts1s_id;
|
||||
@@ -125,7 +127,7 @@ void RunCircle()
|
||||
} else if (circle_type == CIRCLE_RIGHT_RUNNING) // 正常巡线,寻外圆左线
|
||||
{
|
||||
track_type = TRACK_RIGHT;
|
||||
//track_type = TRACK_LEFT; // 看看加一个如果丢线才切换
|
||||
// track_type = TRACK_LEFT; // 看看加一个如果丢线才切换
|
||||
if (Lpt0_found) // 外环存在拐点,可再加拐点距离判据 (左 L 点)
|
||||
{
|
||||
pts_resample_left_count = mid_left_count = Lpt0_rpts0s_id;
|
||||
@@ -149,13 +151,13 @@ void RunCircle()
|
||||
{
|
||||
Right_Border_None_Circle++;
|
||||
}
|
||||
if (pts_resample_right_count > 0.7 / RESAMPLEDIST &&
|
||||
Right_Border_None_Circle > FRAMENONE) {
|
||||
if (pts_resample_right_count > (0.7 / RESAMPLEDIST) && Right_Border_None_Circle > FRAMENONE) {
|
||||
circle_type = CIRCLE_NONE;
|
||||
Right_Border_None_Circle = 0;
|
||||
Right_Border_Have_Circle = 0;
|
||||
Left_Border_ToLeft_Circle = 0;
|
||||
Left_Border_ToRight_Circle = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ enum circle_type_e {
|
||||
};
|
||||
|
||||
extern enum circle_type_e circle_type;
|
||||
extern int32_t ceshi;
|
||||
|
||||
void CheckCircle(void);
|
||||
void RunCircle(void);
|
||||
|
||||
@@ -4,17 +4,19 @@
|
||||
#define IMAGE_H (MT9V03X_H)
|
||||
#define IMAGE_W (MT9V03X_W)
|
||||
#define BEGINH_L (61)
|
||||
#define BEGINH_L_curvature (75)
|
||||
#define BEGINH_R (61)
|
||||
#define BEGINH_R_curvature (75)
|
||||
#define BEGINW_L (-18)
|
||||
#define BEGINW_R (-12)
|
||||
#define PT_MAXLEN (75)
|
||||
#define GET_PIX_1C(IMG, H, W) (IMG[(H) * MT9V03X_W + (W)]) // 获取像素点的值
|
||||
#define FIX_BINTHRESHOLD (140) // 设置最开始的阈值
|
||||
#define SELFADAPT_KERNELSIZE (7) // 巡线区域核大小
|
||||
#define FILTER_KERNELSIZE (7) // 滤波核大小
|
||||
#define SELFADAPT_OFFSET (8) // 适应性块大小
|
||||
#define PIXPERMETER (70.0f)
|
||||
#define PIXPERMETER_ACROSS (72.0f)
|
||||
#define PIXPERMETER_ACROSS_BARRIER (10.0f)
|
||||
#define RESAMPLEDIST (0.02f)
|
||||
#define ANGLEDIST (0.2f)
|
||||
#define ANGLEDIST_barrier (0.06f)
|
||||
|
||||
170
app/gl_cross.c
170
app/gl_cross.c
@@ -5,36 +5,49 @@ enum cross_type_e cross_type = CROSS_NONE;
|
||||
bool far_Lpt0_found, far_Lpt1_found;
|
||||
int32_t Both_Boder_None_Cross;
|
||||
int far_Lpt0_rpts0s_id, far_Lpt1_rpts1s_id;
|
||||
int cross_easy = 0;
|
||||
float cross_open = 1;
|
||||
|
||||
void CheckCross() {
|
||||
void CheckCross()
|
||||
{
|
||||
bool Xfound = Lpt0_found && Lpt1_found;
|
||||
if (cross_type == CROSS_NONE && Xfound){
|
||||
if ((int)cross_open == 0) {
|
||||
if (cross_type == CROSS_NONE && Xfound) {
|
||||
cross_type = CROSS_BEGIN;
|
||||
}
|
||||
}
|
||||
if ((int)cross_open == 1) {
|
||||
if (cross_type == CROSS_NONE && Xfound && cross_easy == 0) {
|
||||
cross_type = CROSS_BEGIN;
|
||||
}
|
||||
if (cross_type == CROSS_NONE && cross_easy == 1 && (((Lpt0_found || Lpt1_found) && (pts_resample_left_count <= 3 || pts_resample_right_count <= 3)) || Xfound)) {
|
||||
cross_type = CROSS_BEGIN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RunCross() {
|
||||
void RunCross()
|
||||
{
|
||||
bool Xfound = Lpt0_found && Lpt1_found;
|
||||
//检测到十字,先按照近线走
|
||||
// 检测到十字,先按照近线走
|
||||
if (cross_easy == 0) {
|
||||
if (cross_type == CROSS_BEGIN) {
|
||||
if (Lpt0_found) {
|
||||
mid_left_count = pts_resample_left_count = Lpt0_rpts0s_id;
|
||||
track_type = TRACK_LEFT;
|
||||
}
|
||||
else if(Lpt1_found) {
|
||||
} else if (Lpt1_found) {
|
||||
mid_right_count = pts_resample_right_count = Lpt1_rpts1s_id;
|
||||
track_type = TRACK_RIGHT;
|
||||
}
|
||||
|
||||
//近角点过少,进入远线控制
|
||||
if ((Xfound && (Lpt0_rpts0s_id < 0.2 / RESAMPLEDIST && Lpt1_rpts1s_id < 0.2 / RESAMPLEDIST)) || (pts_resample_left_count <20 && pts_resample_right_count<20)) {
|
||||
// 近角点过少,进入远线控制
|
||||
if ((Xfound && (Lpt0_rpts0s_id < 0.2 / RESAMPLEDIST && Lpt1_rpts1s_id < 0.2 / RESAMPLEDIST)) || (pts_resample_left_count < 20 && pts_resample_right_count < 20)) {
|
||||
cross_type = CROSS_IN;
|
||||
}
|
||||
|
||||
}
|
||||
//远线控制进十字,begin_y渐变靠近防丢线
|
||||
// 远线控制进十字,begin_y渐变靠近防丢线
|
||||
if (cross_type == CROSS_IN) {
|
||||
//寻远线,算法与近线相同
|
||||
// 寻远线,算法与近线相同
|
||||
cross_farline();
|
||||
|
||||
if (pts_resample_left_count < 5 && pts_resample_right_count < 5) {
|
||||
@@ -43,17 +56,63 @@ void RunCross() {
|
||||
if (Both_Boder_None_Cross > 2 && pts_resample_left_count > 20 && pts_resample_right_count > 20) {
|
||||
cross_type = CROSS_NONE;
|
||||
Both_Boder_None_Cross = 0;
|
||||
cross_easy = 1;
|
||||
}
|
||||
if (far_Lpt1_found) {
|
||||
track_type = TRACK_RIGHT;
|
||||
} else if (far_Lpt0_found) {
|
||||
track_type = TRACK_LEFT;
|
||||
} else if (Both_Boder_None_Cross > 0 && pts_resample_right_count < 5) {
|
||||
track_type = TRACK_RIGHT;
|
||||
} else if (Both_Boder_None_Cross > 0 && pts_resample_left_count < 5) {
|
||||
track_type = TRACK_LEFT;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (far_Lpt1_found) { track_type = TRACK_RIGHT; }
|
||||
else if (far_Lpt0_found) { track_type = TRACK_LEFT; }
|
||||
else if (Both_Boder_None_Cross > 0 && pts_far_resample_right_count < 5) { track_type = TRACK_RIGHT; }
|
||||
else if (Both_Boder_None_Cross > 0 && pts_far_resample_left_count < 5) { track_type = TRACK_LEFT; }
|
||||
|
||||
if (cross_easy == 1) {
|
||||
if (cross_type == CROSS_BEGIN) {
|
||||
if (Lpt0_found) {
|
||||
mid_left_count = pts_resample_left_count = Lpt0_rpts0s_id;
|
||||
track_type = TRACK_LEFT;
|
||||
} else if (Lpt1_found) {
|
||||
mid_right_count = pts_resample_right_count = Lpt1_rpts1s_id;
|
||||
track_type = TRACK_RIGHT;
|
||||
}
|
||||
|
||||
// 近角点过少,进入远线控制
|
||||
if ((Xfound && (Lpt0_rpts0s_id < 0.2 / RESAMPLEDIST && Lpt1_rpts1s_id < 0.2 / RESAMPLEDIST)) || (pts_resample_left_count < 20 && pts_resample_right_count < 20)) {
|
||||
cross_type = CROSS_IN;
|
||||
}
|
||||
}
|
||||
// 远线控制进十字,begin_y渐变靠近防丢线
|
||||
if (cross_type == CROSS_IN) {
|
||||
// 寻远线,算法与近线相同
|
||||
cross_farline();
|
||||
|
||||
if (pts_resample_left_count < 5 && pts_resample_right_count < 5) {
|
||||
Both_Boder_None_Cross++;
|
||||
}
|
||||
if (Both_Boder_None_Cross > 2 && pts_resample_left_count > 20 && pts_resample_right_count > 20) {
|
||||
cross_type = CROSS_NONE;
|
||||
Both_Boder_None_Cross = 0;
|
||||
cross_easy = 0;
|
||||
}
|
||||
if (far_Lpt1_found) {
|
||||
track_type = TRACK_RIGHT;
|
||||
} else if (far_Lpt0_found) {
|
||||
track_type = TRACK_LEFT;
|
||||
} else if (Both_Boder_None_Cross > 0 && pts_resample_right_count < 5) {
|
||||
track_type = TRACK_RIGHT;
|
||||
} else if (Both_Boder_None_Cross > 0 && pts_resample_left_count < 5) {
|
||||
track_type = TRACK_LEFT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void cross_farline(){
|
||||
void cross_farline()
|
||||
{
|
||||
int cross_width = 4;
|
||||
int far_y1 = 0, far_y2 = 0;
|
||||
int far_x1 = 0, far_x2 = 0;
|
||||
@@ -61,78 +120,74 @@ void cross_farline(){
|
||||
pts_far_left_count = sizeof(pts_far_left) / sizeof(pts_far_left[0]);
|
||||
|
||||
int w1 = IMAGE_W / 2 - BEGINW_R, h1 = BEGINH_L;
|
||||
for(;w1>cross_width*2; w1--)
|
||||
{
|
||||
if(GET_PIX_1C(mt9v03x_image_copy[0], h1, w1 - 1) < FIX_BINTHRESHOLD) {
|
||||
for (; w1 > cross_width * 2; w1--) {
|
||||
if (GET_PIX_1C(mt9v03x_image_copy[0], h1, w1 - 1) < FIX_BINTHRESHOLD) {
|
||||
far_x1 = w1 - cross_width;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*如果一行全为白色没写*/
|
||||
if (far_x1 <= 30)
|
||||
{
|
||||
far_x1 = 30;
|
||||
if (far_x1 <= 4) {
|
||||
far_x1 = 4;
|
||||
}
|
||||
|
||||
for (; h1 > 0; h1--) {
|
||||
//先黑后白,先找white
|
||||
// 先黑后白,先找white
|
||||
if (GET_PIX_1C(mt9v03x_image_copy[0], h1, far_x1) >= FIX_BINTHRESHOLD) { white_found = true; }
|
||||
if (GET_PIX_1C(mt9v03x_image_copy[0], h1 - 1, far_x1) < FIX_BINTHRESHOLD && white_found) {
|
||||
far_y1 = h1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (GET_PIX_1C(mt9v03x_image_copy[0], far_y1, far_x1) >= FIX_BINTHRESHOLD){
|
||||
if (GET_PIX_1C(mt9v03x_image_copy[0], far_y1, far_x1) >= FIX_BINTHRESHOLD) {
|
||||
SearchLineAdaptive_Left(mt9v03x_image_copy[0], SELFADAPT_KERNELSIZE, SELFADAPT_OFFSET, far_y1, far_x1, pts_far_left, &pts_far_left_count);
|
||||
}
|
||||
else pts_far_left_count = 0;
|
||||
} else
|
||||
pts_far_left_count = 0;
|
||||
|
||||
int w2 = IMAGE_W / 2 + BEGINW_L, h2 = BEGINH_R;
|
||||
white_found = false;
|
||||
pts_far_right_count = sizeof(pts_far_right) / sizeof(pts_far_right[0]);
|
||||
for(;w2 < IMAGE_W - cross_width*2; w2++)
|
||||
{
|
||||
if(GET_PIX_1C(mt9v03x_image_copy[0], h2, w2 + 1) < FIX_BINTHRESHOLD) {
|
||||
for (; w2 < IMAGE_W - cross_width * 2; w2++) {
|
||||
if (GET_PIX_1C(mt9v03x_image_copy[0], h2, w2 + 1) < FIX_BINTHRESHOLD) {
|
||||
far_x2 = w2 + cross_width;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*如果一行全为白色没写*/
|
||||
if (far_x2 >= 120)
|
||||
{
|
||||
far_x2 = 120;
|
||||
if (far_x2 >= 136) {
|
||||
far_x2 = 136;
|
||||
}
|
||||
|
||||
for (; h2 > 0; h2--) {
|
||||
//先黑后白,先找white
|
||||
// 先黑后白,先找white
|
||||
if (GET_PIX_1C(mt9v03x_image_copy[0], h2, far_x2) >= FIX_BINTHRESHOLD) { white_found = true; }
|
||||
if (GET_PIX_1C(mt9v03x_image_copy[0], h2 - 1, far_x2) < FIX_BINTHRESHOLD && white_found) {
|
||||
far_y2 = h2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (GET_PIX_1C(mt9v03x_image_copy[0], far_y2, far_x2) >= FIX_BINTHRESHOLD){
|
||||
if (GET_PIX_1C(mt9v03x_image_copy[0], far_y2, far_x2) >= FIX_BINTHRESHOLD) {
|
||||
SearchLineAdaptive_Right(mt9v03x_image_copy[0], SELFADAPT_KERNELSIZE, SELFADAPT_OFFSET, far_y2, far_x2, pts_far_right, &pts_far_right_count);
|
||||
}
|
||||
else pts_far_right_count = 0;
|
||||
} else
|
||||
pts_far_right_count = 0;
|
||||
|
||||
//透视变换
|
||||
// 透视变换
|
||||
for (int i = 0; i < pts_far_left_count; i++) {
|
||||
pts_far_inv_l[i][1] = fclip(InverseMapW[pts_far_left[i][0]][pts_far_left[i][1]],0,IMAGE_W);
|
||||
pts_far_inv_l[i][0] = fclip(InverseMapH[pts_far_left[i][0]][pts_far_left[i][1]],0,IMAGE_H);
|
||||
pts_far_inv_l[i][1] = fclip(InverseMapW[pts_far_left[i][0]][pts_far_left[i][1]], 0, IMAGE_W);
|
||||
pts_far_inv_l[i][0] = fclip(InverseMapH[pts_far_left[i][0]][pts_far_left[i][1]], 0, IMAGE_H);
|
||||
}
|
||||
pts_far_inv_l_count = pts_far_left_count;
|
||||
|
||||
for (int i = 0; i < pts_far_right_count; i++) {
|
||||
pts_far_inv_r[i][1] = fclip(InverseMapW[pts_far_right[i][0]][pts_far_right[i][1]],0,IMAGE_W);
|
||||
pts_far_inv_r[i][0] = fclip(InverseMapH[pts_far_right[i][0]][pts_far_right[i][1]],0,IMAGE_H);
|
||||
pts_far_inv_r[i][1] = fclip(InverseMapW[pts_far_right[i][0]][pts_far_right[i][1]], 0, IMAGE_W);
|
||||
pts_far_inv_r[i][0] = fclip(InverseMapH[pts_far_right[i][0]][pts_far_right[i][1]], 0, IMAGE_H);
|
||||
}
|
||||
pts_far_inv_r_count = pts_far_right_count;
|
||||
|
||||
// 边线滤波
|
||||
GetLinesFilter(pts_far_inv_l, pts_far_inv_l_count, pts_far_filter_l, (int) round(FILTER_KERNELSIZE));
|
||||
GetLinesFilter(pts_far_inv_l, pts_far_inv_l_count, pts_far_filter_l, (int)round(FILTER_KERNELSIZE));
|
||||
pts_far_filter_l_count = pts_far_inv_l_count;
|
||||
GetLinesFilter(pts_far_inv_r, pts_far_inv_r_count, pts_far_filter_r, (int) round(FILTER_KERNELSIZE));
|
||||
GetLinesFilter(pts_far_inv_r, pts_far_inv_r_count, pts_far_filter_r, (int)round(FILTER_KERNELSIZE));
|
||||
pts_far_filter_r_count = pts_far_inv_r_count;
|
||||
|
||||
// 边线等距采样
|
||||
@@ -141,14 +196,13 @@ void cross_farline(){
|
||||
pts_far_resample_right_count = sizeof(pts_far_resample_right) / sizeof(pts_far_resample_right[0]);
|
||||
GetLinesResample(pts_far_filter_r, pts_far_filter_r_count, pts_far_resample_right, &pts_far_resample_right_count, RESAMPLEDIST * PIXPERMETER);
|
||||
|
||||
|
||||
int valid_far_points_count = 0;
|
||||
|
||||
for (int i = 0; i < pts_far_resample_left_count; i++) {
|
||||
int x = pts_far_resample_left[i][1];
|
||||
int y = pts_far_resample_left[i][0];
|
||||
|
||||
if (y < IMAGE_H-3 && x > 3 && x < IMAGE_W-3 && y>=3 ) {
|
||||
if (y < IMAGE_H - 3 && x > 3 && x < IMAGE_W - 3 && y >= 3) {
|
||||
pts_far_resample_left[valid_far_points_count][0] = pts_far_resample_left[i][0];
|
||||
pts_far_resample_left[valid_far_points_count][1] = pts_far_resample_left[i][1];
|
||||
valid_far_points_count++;
|
||||
@@ -162,7 +216,7 @@ void cross_farline(){
|
||||
int x = pts_far_resample_right[i][1];
|
||||
int y = pts_far_resample_right[i][0];
|
||||
|
||||
if (y <= IMAGE_H-3 && x >= 3 && x <= IMAGE_W-3 && y>=3) {
|
||||
if (y <= IMAGE_H - 3 && x >= 3 && x <= IMAGE_W - 3 && y >= 3) {
|
||||
pts_far_resample_right[valid_far_points_count][0] = pts_far_resample_right[i][0];
|
||||
pts_far_resample_right[valid_far_points_count][1] = pts_far_resample_right[i][1];
|
||||
valid_far_points_count++;
|
||||
@@ -172,15 +226,15 @@ void cross_farline(){
|
||||
pts_far_resample_right_count = valid_far_points_count;
|
||||
|
||||
// 边线角度变化率
|
||||
local_angle_points(pts_far_resample_left, pts_far_resample_left_count, far_angle_left, (int) round(ANGLEDIST / RESAMPLEDIST));
|
||||
local_angle_points(pts_far_resample_left, pts_far_resample_left_count, far_angle_left, (int)round(ANGLEDIST / RESAMPLEDIST));
|
||||
far_angle_left_num = pts_far_resample_left_count;
|
||||
local_angle_points(pts_far_resample_right, pts_far_resample_right_count, far_angle_right, (int) round(ANGLEDIST / RESAMPLEDIST));
|
||||
local_angle_points(pts_far_resample_right, pts_far_resample_right_count, far_angle_right, (int)round(ANGLEDIST / RESAMPLEDIST));
|
||||
far_angle_right_num = pts_far_resample_right_count;
|
||||
|
||||
// 角度变化率非极大值抑制
|
||||
nms_angle(far_angle_left, far_angle_left_num, far_angle_new_left, (int) round(ANGLEDIST / RESAMPLEDIST) * 2 + 1);
|
||||
nms_angle(far_angle_left, far_angle_left_num, far_angle_new_left, (int)round(ANGLEDIST / RESAMPLEDIST) * 2 + 1);
|
||||
far_angle_new_left_num = far_angle_left_num;
|
||||
nms_angle(far_angle_right, far_angle_right_num, far_angle_new_right, (int) round(ANGLEDIST / RESAMPLEDIST) * 2 + 1);
|
||||
nms_angle(far_angle_right, far_angle_right_num, far_angle_new_right, (int)round(ANGLEDIST / RESAMPLEDIST) * 2 + 1);
|
||||
far_angle_new_right_num = far_angle_right_num;
|
||||
|
||||
// 找远线上的L角点
|
||||
@@ -189,30 +243,26 @@ void cross_farline(){
|
||||
// is_far_straight1 = pts_far_resample_right_count > 1.0 / RESAMPLEDIST;
|
||||
for (int i = 0; i < pts_far_resample_left_count; i++) {
|
||||
if (far_angle_new_left[i] == 0) continue;
|
||||
int im1 = clip(i - (int) round(ANGLEDIST / RESAMPLEDIST), 0, pts_far_resample_left_count - 1);
|
||||
int ip1 = clip(i + (int) round(ANGLEDIST / RESAMPLEDIST), 0, pts_far_resample_left_count - 1);
|
||||
int im1 = clip(i - (int)round(ANGLEDIST / RESAMPLEDIST), 0, pts_far_resample_left_count - 1);
|
||||
int ip1 = clip(i + (int)round(ANGLEDIST / RESAMPLEDIST), 0, pts_far_resample_left_count - 1);
|
||||
float conf = fabs(far_angle_left[i]) - (fabs(far_angle_left[im1]) + fabs(far_angle_left[ip1])) / 2;
|
||||
|
||||
//L角点阈值
|
||||
// L角点阈值
|
||||
if (far_Lpt0_found == false && (66. / 180. * PI32) < conf && conf < (140. / 180. * PI32) && i < 0.7 / RESAMPLEDIST) {
|
||||
far_Lpt0_rpts0s_id = i;
|
||||
far_Lpt0_found = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < pts_far_resample_right_count; i++) {
|
||||
if (far_angle_new_right[i] == 0) continue;
|
||||
int im1 = clip(i - (int) round(ANGLEDIST / RESAMPLEDIST), 0, pts_far_resample_right_count - 1);
|
||||
int ip1 = clip(i + (int) round(ANGLEDIST / RESAMPLEDIST), 0, pts_far_resample_right_count - 1);
|
||||
int im1 = clip(i - (int)round(ANGLEDIST / RESAMPLEDIST), 0, pts_far_resample_right_count - 1);
|
||||
int ip1 = clip(i + (int)round(ANGLEDIST / RESAMPLEDIST), 0, pts_far_resample_right_count - 1);
|
||||
float conf = fabs(far_angle_right[i]) - (fabs(far_angle_right[im1]) + fabs(far_angle_right[ip1])) / 2;
|
||||
|
||||
|
||||
if (far_Lpt1_found == false && (66. / 180. * PI32) < conf && conf < 140. / 180. * PI32 && i < 0.7 / RESAMPLEDIST) {
|
||||
far_Lpt1_rpts1s_id = i;
|
||||
far_Lpt1_found = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@ enum cross_type_e {
|
||||
extern enum cross_type_e cross_type;
|
||||
extern int32_t Both_Boder_None_Cross;
|
||||
extern int far_Lpt0_rpts0s_id, far_Lpt1_rpts1s_id;
|
||||
extern float cross_open;
|
||||
|
||||
void CheckCross(void);
|
||||
void RunCross(void);
|
||||
|
||||
@@ -6,6 +6,11 @@ int32_t pts_left[PT_MAXLEN][2];
|
||||
int32_t pts_right[PT_MAXLEN][2];
|
||||
int32_t pts_left_count;
|
||||
int32_t pts_right_count;
|
||||
int32_t pts_left_curvature[PT_MAXLEN][2];
|
||||
int32_t pts_right_curvature[PT_MAXLEN][2];
|
||||
int32_t pts_left_count_curvature;
|
||||
int32_t pts_right_count_curvature;
|
||||
int32_t mid_s_count;
|
||||
int32_t pts_far_left[PT_MAXLEN][2];
|
||||
int32_t pts_far_right[PT_MAXLEN][2];
|
||||
int32_t pts_far_left_count;
|
||||
@@ -42,9 +47,15 @@ int32_t pts_far_resample_right_count;
|
||||
|
||||
float mid_left[PT_MAXLEN][2];
|
||||
float mid_right[PT_MAXLEN][2];
|
||||
float mid_left_barrier[PT_MAXLEN][2];
|
||||
float mid_right_barrier[PT_MAXLEN][2];
|
||||
|
||||
float mid_s[PT_MAXLEN][2];
|
||||
|
||||
int32_t mid_left_count;
|
||||
int32_t mid_right_count;
|
||||
int32_t mid_left_barrier_count;
|
||||
int32_t mid_right_barrier_count;
|
||||
|
||||
float angle_new_left[PT_MAXLEN];
|
||||
float angle_new_right[PT_MAXLEN];
|
||||
@@ -112,5 +123,8 @@ float rptsn[PT_MAXLEN][2];
|
||||
int32_t rptsn_num;
|
||||
float aim_distance;
|
||||
float aim_judge_far=0.3f;
|
||||
float FIX_BINTHRESHOLD = 140;
|
||||
|
||||
track_type_e track_type = TRACK_RIGHT;
|
||||
|
||||
int begin_flag = 0;
|
||||
@@ -16,10 +16,15 @@ extern int32_t pts_left[PT_MAXLEN][2];
|
||||
extern int32_t pts_right[PT_MAXLEN][2];
|
||||
extern int32_t pts_left_count;
|
||||
extern int32_t pts_right_count;
|
||||
extern int32_t pts_left_curvature[PT_MAXLEN][2];
|
||||
extern int32_t pts_right_curvature[PT_MAXLEN][2];
|
||||
extern int32_t pts_left_count_curvature;
|
||||
extern int32_t pts_right_count_curvature;
|
||||
extern int32_t pts_far_left[PT_MAXLEN][2];
|
||||
extern int32_t pts_far_right[PT_MAXLEN][2];
|
||||
extern int32_t pts_far_left_count;
|
||||
extern int32_t pts_far_right_count;
|
||||
extern int32_t mid_s_count;
|
||||
//逆透视后边线数组
|
||||
extern float pts_inv_l[PT_MAXLEN][2];
|
||||
extern float pts_inv_r[PT_MAXLEN][2];
|
||||
@@ -51,9 +56,15 @@ extern int32_t pts_far_resample_right_count;
|
||||
|
||||
extern float mid_left[PT_MAXLEN][2];
|
||||
extern float mid_right[PT_MAXLEN][2];
|
||||
extern float mid_s[PT_MAXLEN][2];
|
||||
extern float mid_left_barrier[PT_MAXLEN][2];
|
||||
extern float mid_right_barrier[PT_MAXLEN][2];
|
||||
|
||||
extern int32_t mid_left_count;
|
||||
extern int32_t mid_right_count;
|
||||
extern int32_t mid_left_barrier_count;
|
||||
extern int32_t mid_right_barrier_count;
|
||||
|
||||
|
||||
extern float angle_new_left[PT_MAXLEN];
|
||||
extern float angle_new_right[PT_MAXLEN];
|
||||
@@ -125,5 +136,7 @@ extern float aim_distance;
|
||||
extern float aim_judge_far;
|
||||
|
||||
extern track_type_e track_type;
|
||||
extern float FIX_BINTHRESHOLD;
|
||||
extern int begin_flag;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -44,7 +44,7 @@ void CheckGarage()
|
||||
int banmaxian_hangshu = 0;//斑马线行数
|
||||
|
||||
//从下往上扫描
|
||||
for (int y = BEGINH_L - 6; y >= BEGINH_L - 9; y--)
|
||||
for (int y = BEGINH_L + 4; y >= BEGINH_L - 4; y--)
|
||||
{
|
||||
int banmaxian_kuandu=0;
|
||||
//int banmaxian_hangshu=0;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
enum garage_type_e {
|
||||
GARAGE_NONE, // 非车库模式
|
||||
GARAGE_FOUND,
|
||||
OUT_STOP,
|
||||
};
|
||||
extern enum garage_type_e garage_type;
|
||||
|
||||
|
||||
@@ -59,10 +59,18 @@ void get_corners()
|
||||
float conf = fabs(angle_left_barrier[i]) - (fabs(angle_left_barrier[im1]) + fabs(angle_left_barrier[ip1])) / 2;
|
||||
|
||||
// L 角点阈值
|
||||
if (Lpt0_found_barrier == false && (66. / 180. * PI32) < conf && conf < (140. / 180. * PI32) && i < 0.5 / RESAMPLEDIST) {
|
||||
if (Lpt0_found_barrier == false && (40. / 180. * PI32) < conf && conf < (160. / 180. * PI32) && i < 0.6 / RESAMPLEDIST) {
|
||||
Lpt0_rpts0s_id_barrier = i;
|
||||
if (pts_resample_left[i][1] <= pts_resample_left[clip(i + 2, 0, pts_resample_left_count - 1)][1])
|
||||
{
|
||||
Lpt0_found_barrier = true;
|
||||
}
|
||||
else{
|
||||
Lpt0_found_barrier = false;
|
||||
}
|
||||
|
||||
//Lpt0_found_barrier = true;
|
||||
}
|
||||
}
|
||||
if (Lpt0_found_barrier) {
|
||||
float angle1 = calculate_vector_angle(pts_resample_left[Lpt0_rpts0s_id_barrier][1], pts_resample_left[Lpt0_rpts0s_id_barrier][0], pts_resample_left[Lpt0_rpts0s_id_barrier + 5][1], pts_resample_left[Lpt0_rpts0s_id_barrier + 5][0]);
|
||||
@@ -73,6 +81,9 @@ void get_corners()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < pts_resample_right_count; i++) {
|
||||
if (angle_new_right[i] == 0) continue;
|
||||
int im1 = clip(i - (int)round(ANGLEDIST / RESAMPLEDIST), 0, pts_resample_right_count - 1);
|
||||
@@ -116,10 +127,18 @@ void get_corners()
|
||||
int ip1 = clip(i + (int)round(ANGLEDIST_barrier / RESAMPLEDIST), 0, pts_resample_right_count - 1);
|
||||
float conf = fabs(angle_right_barrier[i]) - (fabs(angle_right_barrier[im1]) + fabs(angle_right_barrier[ip1])) / 2;
|
||||
|
||||
if (Lpt1_found_barrier == false && (66. / 180. * PI32) < conf && conf < 140. / 180. * PI32 && i < 0.5 / RESAMPLEDIST) {
|
||||
if (Lpt1_found_barrier == false && (40. / 180. * PI32) < conf && conf < 160. / 180. * PI32 && i < 0.6 / RESAMPLEDIST) {
|
||||
Lpt1_rpts1s_id_barrier = i;
|
||||
|
||||
if (pts_resample_right[i][1] >= pts_resample_right[clip(i + 2, 0, pts_resample_left_count - 1)][1])
|
||||
{
|
||||
Lpt1_found_barrier = true;
|
||||
}
|
||||
else{
|
||||
Lpt1_found_barrier = false;
|
||||
}
|
||||
//Lpt1_found_barrier = true;
|
||||
}
|
||||
}
|
||||
if (Lpt1_found_barrier) {
|
||||
float angle2 = calculate_vector_angle(pts_resample_right[Lpt1_rpts1s_id_barrier][1], pts_resample_right[Lpt1_rpts1s_id_barrier][0], pts_resample_right[Lpt1_rpts1s_id_barrier + 5][1], pts_resample_right[Lpt1_rpts1s_id_barrier + 5][0]);
|
||||
|
||||
@@ -237,3 +237,4 @@ int is_curve(float angle[], int n, float threshold) {
|
||||
return 0; // 不是弯道
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
void img_processing() {
|
||||
|
||||
|
||||
//
|
||||
int w1 = IMAGE_W / 2 - BEGINW_R, h1 = BEGINH_L;
|
||||
pts_left_count = sizeof(pts_left) / sizeof(pts_left[0]);
|
||||
for (; w1 > 0; w1--) {
|
||||
@@ -23,6 +23,20 @@ void img_processing() {
|
||||
SearchLineAdaptive_Left(mt9v03x_image_copy[0], SELFADAPT_KERNELSIZE, SELFADAPT_OFFSET, h1, w1, pts_left, &pts_left_count);
|
||||
}
|
||||
else pts_left_count = 0;
|
||||
//算曲率
|
||||
int w1_curvature = IMAGE_W / 2 - BEGINW_R, h1_curvature = BEGINH_L_curvature;
|
||||
pts_left_count_curvature = sizeof(pts_left_curvature) / sizeof(pts_left_curvature[0]);
|
||||
for (; w1_curvature > 0; w1_curvature--) {
|
||||
if (GET_PIX_1C(mt9v03x_image_copy[0], h1_curvature, w1_curvature - 1) < FIX_BINTHRESHOLD)
|
||||
break;
|
||||
}
|
||||
|
||||
if (GET_PIX_1C(mt9v03x_image_copy[0], h1_curvature, w1_curvature) >= FIX_BINTHRESHOLD){
|
||||
SearchLineAdaptive_Left(mt9v03x_image_copy[0], SELFADAPT_KERNELSIZE, SELFADAPT_OFFSET, h1_curvature, w1_curvature, pts_left_curvature, &pts_left_count_curvature);
|
||||
}
|
||||
else pts_left_count_curvature = 0;
|
||||
|
||||
|
||||
|
||||
int w2 = IMAGE_W / 2 + BEGINW_L, h2 = BEGINH_R;
|
||||
pts_right_count = sizeof(pts_right) / sizeof(pts_right[0]);
|
||||
@@ -35,6 +49,18 @@ void img_processing() {
|
||||
SearchLineAdaptive_Right(mt9v03x_image_copy[0], SELFADAPT_KERNELSIZE, SELFADAPT_OFFSET, h2, w2, pts_right, &pts_right_count);
|
||||
}
|
||||
else pts_right_count = 0;
|
||||
//算曲率
|
||||
int w2_curvature = IMAGE_W / 2 + BEGINW_L, h2_curvature = BEGINH_R_curvature;
|
||||
pts_right_count_curvature = sizeof(pts_right_curvature) / sizeof(pts_right_curvature[0]);
|
||||
for (; w2_curvature < IMAGE_W - 1; w2_curvature++) {
|
||||
if (GET_PIX_1C(mt9v03x_image_copy[0], h2_curvature, w2_curvature + 1) < FIX_BINTHRESHOLD)
|
||||
break;
|
||||
}
|
||||
|
||||
if (GET_PIX_1C(mt9v03x_image_copy[0], h2_curvature, w2_curvature) >= FIX_BINTHRESHOLD){
|
||||
SearchLineAdaptive_Right(mt9v03x_image_copy[0], SELFADAPT_KERNELSIZE, SELFADAPT_OFFSET, h2_curvature, w2_curvature, pts_right_curvature, &pts_right_count_curvature);
|
||||
}
|
||||
else pts_right_count_curvature = 0;
|
||||
|
||||
//透视变换
|
||||
for (int i = 0; i < pts_left_count; i++) {
|
||||
@@ -87,6 +113,7 @@ void img_processing() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pts_resample_right_count = valid_points_count;
|
||||
|
||||
// 大距离边线角度变化率
|
||||
@@ -119,5 +146,11 @@ void img_processing() {
|
||||
GetMidLine_Right(pts_resample_right, pts_resample_right_count, mid_right, (int) round(ANGLEDIST / RESAMPLEDIST), PIXPERMETER_ACROSS * ROADWIDTH / 2);
|
||||
mid_right_count = pts_resample_right_count;
|
||||
|
||||
// 左右中线跟踪(避障专属)
|
||||
GetMidLine_Left(pts_resample_left, pts_resample_left_count, mid_left_barrier, (int) round(ANGLEDIST / RESAMPLEDIST), PIXPERMETER_ACROSS_BARRIER * ROADWIDTH / 2);
|
||||
mid_left_barrier_count = pts_resample_left_count;
|
||||
GetMidLine_Right(pts_resample_right, pts_resample_right_count, mid_right_barrier, (int) round(ANGLEDIST / RESAMPLEDIST), PIXPERMETER_ACROSS_BARRIER * ROADWIDTH / 2);
|
||||
mid_right_barrier_count = pts_resample_right_count;
|
||||
|
||||
|
||||
}
|
||||
@@ -2,8 +2,12 @@
|
||||
#include "gl_headfile.h"
|
||||
|
||||
enum state_type_e state_type =0;
|
||||
enum state_type_e last_state =0;
|
||||
float cricle_aim=0.2f;
|
||||
float cross_aim=0.49f;
|
||||
float common_aim=0.35f;
|
||||
float straight_aim=0.35f;
|
||||
float turn_aim=0.35f;
|
||||
float mid_aim=0.5f;
|
||||
float barrier_aim=0.5f;
|
||||
float barrier_offset=17.0f;
|
||||
float barrier_offset=10.0f;
|
||||
@@ -6,12 +6,17 @@ enum state_type_e {
|
||||
TURN_STATE,
|
||||
STRAIGHT_STATE,
|
||||
CIRCLE_STATE,
|
||||
CIRCLE_RUNNING_STATE,
|
||||
BARRIER_STATE,
|
||||
};
|
||||
|
||||
extern enum state_type_e last_state;
|
||||
extern enum state_type_e state_type;
|
||||
extern float cricle_aim;
|
||||
extern float cross_aim;
|
||||
extern float common_aim;
|
||||
extern float straight_aim;
|
||||
extern float turn_aim;
|
||||
extern float mid_aim;
|
||||
extern float barrier_aim;
|
||||
extern float barrier_offset;
|
||||
|
||||
|
||||
@@ -1,14 +1,23 @@
|
||||
#include "zf_common_headfile.h"
|
||||
#include "gl_headfile.h"
|
||||
#include "jj_blueteeth.h"
|
||||
#include <float.h>
|
||||
float (*mid_track)[2];
|
||||
int32_t mid_track_count;
|
||||
float pure_angle;
|
||||
float pure_angle_half;
|
||||
float curvature;
|
||||
float dx_near;
|
||||
float curvature;
|
||||
float last_curvature;
|
||||
float (*rpts)[2];
|
||||
int rpts_num;
|
||||
float last_pure_angle = 0.0f;
|
||||
|
||||
int8_t turn_flag = 0;
|
||||
int circle_flag = 1;
|
||||
int pingbi_num = 0;
|
||||
int last_garage_type = GARAGE_NONE;
|
||||
float turn_threshold = 12.0f;
|
||||
// 计算最小二乘法斜率的函数
|
||||
float leastSquaresSlope(float points[][2], int n)
|
||||
{
|
||||
@@ -40,7 +49,41 @@ float leastSquaresSlope(float points[][2], int n)
|
||||
return temp;
|
||||
}
|
||||
|
||||
float calculateX(float a_x, float a_y, float slope, float b_y) {
|
||||
// 计算曲率的函数
|
||||
// 计算曲率的函数
|
||||
float calculate_curvature(float x[], float y[], int n)
|
||||
{
|
||||
float total_curvature = 0.0;
|
||||
|
||||
for (int i = 1; i < n - 1; i++) {
|
||||
float x1 = x[i - 1], y1 = y[i - 1];
|
||||
float x2 = x[i], y2 = y[i];
|
||||
float x3 = x[i + 1], y3 = y[i + 1];
|
||||
|
||||
float dx1 = x2 - x1;
|
||||
float dy1 = y2 - y1;
|
||||
float dx2 = x3 - x2;
|
||||
float dy2 = y3 - y2;
|
||||
|
||||
float dx = (dx1 + dx2) / 2;
|
||||
float dy = (dy1 + dy2) / 2;
|
||||
|
||||
float ddx = x3 - 2 * x2 + x1;
|
||||
float ddy = y3 - 2 * y2 + y1;
|
||||
|
||||
float numerator = dx * ddy - dy * ddx;
|
||||
float denominator = powf(dx * dx + dy * dy, 1.5f);
|
||||
|
||||
if (fabs(denominator) > FLT_EPSILON) {
|
||||
total_curvature += numerator / denominator;
|
||||
}
|
||||
}
|
||||
|
||||
return total_curvature / (float)(n - 2);
|
||||
}
|
||||
|
||||
float calculateX(float a_x, float a_y, float slope, float b_y)
|
||||
{
|
||||
float b_x = a_x - (b_y - a_y) * slope;
|
||||
return b_x;
|
||||
}
|
||||
@@ -62,18 +105,18 @@ void tracking()
|
||||
void aim_distance_select(void)
|
||||
{
|
||||
if (cross_type != CROSS_NONE) {
|
||||
aim_distance = cricle_aim;
|
||||
} else if (circle_type != CIRCLE_NONE) {
|
||||
aim_distance = cross_aim;
|
||||
} else if (circle_type != CIRCLE_NONE) {
|
||||
aim_distance = cricle_aim;
|
||||
} else if (barrier_type != BARRIER_NONE) {
|
||||
aim_distance = barrier_aim;
|
||||
} else {
|
||||
aim_distance = common_aim;
|
||||
}
|
||||
}
|
||||
|
||||
void ElementJudge()
|
||||
{
|
||||
|
||||
if (shield_type == SHIELD_NONE) {
|
||||
CheckGarage();
|
||||
if (garage_type == GARAGE_NONE) {
|
||||
CheckCross();
|
||||
@@ -81,6 +124,10 @@ void ElementJudge()
|
||||
CheckBarrier();
|
||||
if (barrier_type == BARRIER_NONE) {
|
||||
CheckCircle();
|
||||
if (circle_type == CIRCLE_NONE) {
|
||||
Check_s();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,6 +135,7 @@ void ElementJudge()
|
||||
if (garage_type != GARAGE_NONE) {
|
||||
cross_type = CROSS_NONE;
|
||||
circle_type = CIRCLE_NONE;
|
||||
barrier_type = BARRIER_NONE;
|
||||
}
|
||||
if (cross_type != CROSS_NONE) {
|
||||
circle_type = CIRCLE_NONE;
|
||||
@@ -106,17 +154,22 @@ void ElementRun()
|
||||
|
||||
else if (cross_type != CROSS_NONE) {
|
||||
RunCross();
|
||||
}
|
||||
|
||||
else if (circle_type != CIRCLE_NONE) {
|
||||
RunCircle();
|
||||
} else if (barrier_type != BARRIER_NONE) {
|
||||
RunBarrier();
|
||||
} else if (circle_type != CIRCLE_NONE) {
|
||||
RunCircle();
|
||||
} else if (s_type != S_NONE) {
|
||||
// RunS();
|
||||
}
|
||||
}
|
||||
|
||||
void MidLineTrack()
|
||||
{
|
||||
// if (shield_type == SHIELD_BEGIN) {
|
||||
// shield_type = SHIELD_NONE;
|
||||
// pure_angle = 0.f;
|
||||
// system_delay_ms(3500); // 斑马线发车延时
|
||||
// }
|
||||
if (cross_type == CROSS_IN) {
|
||||
if (track_type == TRACK_LEFT) {
|
||||
mid_track = mid_left; // 这是为了预先分配内存
|
||||
@@ -127,6 +180,14 @@ void MidLineTrack()
|
||||
GetMidLine_Right(pts_far_resample_right + far_Lpt1_rpts1s_id, pts_far_resample_right_count - far_Lpt1_rpts1s_id, mid_right, (int)round(ANGLEDIST / RESAMPLEDIST), PIXPERMETER * ROADWIDTH / 2);
|
||||
mid_track_count = pts_far_resample_right_count - far_Lpt1_rpts1s_id;
|
||||
}
|
||||
} else if (barrier_type == BARRIER_LEFT_RUNNING || barrier_type == BARRIER_RIGHT_RUNNING) {
|
||||
if (track_type == TRACK_LEFT) {
|
||||
mid_track = mid_left_barrier;
|
||||
mid_track_count = mid_left_barrier_count;
|
||||
} else {
|
||||
mid_track = mid_right_barrier;
|
||||
mid_track_count = mid_right_barrier_count;
|
||||
}
|
||||
} else {
|
||||
if (track_type == TRACK_LEFT) {
|
||||
mid_track = mid_left;
|
||||
@@ -135,66 +196,29 @@ void MidLineTrack()
|
||||
mid_track = mid_right;
|
||||
mid_track_count = mid_right_count;
|
||||
}
|
||||
float x[mid_track_count];
|
||||
float y[mid_track_count];
|
||||
|
||||
for (int i = 0; i < mid_track_count; i++) {
|
||||
x[i] = mid_track[i][1];
|
||||
y[i] = mid_track[i][0];
|
||||
}
|
||||
|
||||
if (mid_track_count <= 5) {
|
||||
curvature = last_curvature;
|
||||
/* code */
|
||||
} else {
|
||||
curvature = calculate_curvature(x, y, mid_track_count);
|
||||
}
|
||||
last_curvature = curvature;
|
||||
}
|
||||
|
||||
// 车轮对应点 (纯跟踪起始点)
|
||||
float cx = InverseMapW[(int)(IMAGE_H * 0.8f)][70];
|
||||
float cy = InverseMapH[(int)(IMAGE_H * 0.8f)][70];
|
||||
|
||||
|
||||
// float slope = leastSquaresSlope(mid_track, mid_track_count);
|
||||
int neary = mid_track[0][0];
|
||||
int nearx = mid_track[0][1];
|
||||
// float near_distance = calculateX(a_x, a_y, slope, cy);
|
||||
int w1 = (int)cx;
|
||||
int h1 = (int)cy;
|
||||
int near_x1 = 0;
|
||||
int near_x2 = 0;
|
||||
if (GET_PIX_1C(mt9v03x_image_copy[0], h1, w1) >= FIX_BINTHRESHOLD)
|
||||
{
|
||||
for(;w1>10; w1--)
|
||||
{
|
||||
if(GET_PIX_1C(mt9v03x_image_copy[0], h1, w1 - 1) < FIX_BINTHRESHOLD) {
|
||||
near_x1 = w1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for(;w1<130; w1++)
|
||||
{
|
||||
if(GET_PIX_1C(mt9v03x_image_copy[0], h1, w1 + 1) < FIX_BINTHRESHOLD) {
|
||||
near_x2 = w1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GET_PIX_1C(mt9v03x_image_copy[0], h1, w1 - BEGINW_R) < FIX_BINTHRESHOLD)
|
||||
{
|
||||
for(;w1>10; w1--)
|
||||
{
|
||||
if(GET_PIX_1C(mt9v03x_image_copy[0], h1, w1 - 1) > FIX_BINTHRESHOLD && GET_PIX_1C(mt9v03x_image_copy[0], h1, w1 - 2) > FIX_BINTHRESHOLD) {
|
||||
near_x1 = w1;
|
||||
near_x2 = cx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (GET_PIX_1C(mt9v03x_image_copy[0], h1, w1 + BEGINW_R) < FIX_BINTHRESHOLD)
|
||||
{
|
||||
for(;w1<130; w1++)
|
||||
{
|
||||
if(GET_PIX_1C(mt9v03x_image_copy[0], h1, w1 + 1) > FIX_BINTHRESHOLD && GET_PIX_1C(mt9v03x_image_copy[0], h1, w1 + 2) > FIX_BINTHRESHOLD) {
|
||||
near_x1 = cx;
|
||||
near_x2 = w1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int neary = (int)mid_track[0][0];
|
||||
int nearx = (int)mid_track[0][1];
|
||||
|
||||
// 找最近点 (起始点中线归一化)
|
||||
float min_dist = 1e10;
|
||||
@@ -217,12 +241,29 @@ void MidLineTrack()
|
||||
rptsn_num = sizeof(rptsn) / sizeof(rptsn[0]);
|
||||
GetLinesResample(mid_track + begin_id, mid_track_count - begin_id, rptsn, &rptsn_num, RESAMPLEDIST * PIXPERMETER);
|
||||
|
||||
if (cross_type == CROSS_IN) {
|
||||
float x[rptsn_num];
|
||||
float y[rptsn_num];
|
||||
|
||||
for (int i = 0; i < rptsn_num; i++) {
|
||||
x[i] = rptsn[i][1];
|
||||
y[i] = rptsn[i][0];
|
||||
}
|
||||
if (rptsn_num <= 5) {
|
||||
curvature = last_curvature;
|
||||
/* code */
|
||||
} else {
|
||||
curvature = calculate_curvature(x, y, rptsn_num);
|
||||
}
|
||||
last_curvature = curvature;
|
||||
}
|
||||
|
||||
// 远预锚点位置-
|
||||
int aim_idx = clip(round(aim_distance / RESAMPLEDIST), 0, rptsn_num - 1);
|
||||
int aim_idx_judge = clip(round(aim_judge_far / RESAMPLEDIST), 0, mid_track_count - 1);
|
||||
|
||||
// 近锚点位置
|
||||
int aim_idx_near = clip(round(0.09 / RESAMPLEDIST), 0, rptsn_num - 1);
|
||||
int aim_idx_near = clip(round(aim_distance / 2 / RESAMPLEDIST), 0, rptsn_num - 1);
|
||||
|
||||
float dx1 = mid_track[3 * (mid_track_count / 4)][1] - mid_track[aim_idx_judge][1];
|
||||
float dy1 = mid_track[3 * (mid_track_count / 4)][0] - mid_track[aim_idx_judge][0];
|
||||
@@ -235,6 +276,7 @@ void MidLineTrack()
|
||||
float c2 = dx2 / dn2;
|
||||
float s2 = dy2 / dn2;
|
||||
float angle_1 = atan2f(c1 * s2 - c2 * s1, c2 * c1 + s2 * s1);
|
||||
|
||||
if (angle_1 >= 0.2f || angle_1 <= -0.2f) {
|
||||
state_type = TURN_STATE;
|
||||
} else {
|
||||
@@ -246,54 +288,130 @@ void MidLineTrack()
|
||||
float dy = cy - rptsn[aim_idx][0]; // + 0.2f * PIXPERMETER;
|
||||
float dn = (dx * dx + dy * dy);
|
||||
float temp_near = 0;
|
||||
if (barrier_type == BARRIER_LEFT_BEGIN || barrier_type == BARRIER_LEFT_RUNNING) {
|
||||
dx_near = mid_track[aim_idx_near][1] - cx + barrier_offset;
|
||||
pure_angle = -atanf(PIXPERMETER * 2.0f * 0.2f * dx / dn) / PI32 * 180.0f - 20;
|
||||
} else if (barrier_type == BARRIER_RIGHT_BEGIN || barrier_type == BARRIER_RIGHT_RUNNING ) {
|
||||
dx_near = mid_track[aim_idx_near][1] - cx - barrier_offset;
|
||||
pure_angle = -atanf(PIXPERMETER * 2.0f * 0.2f * dx / dn) / PI32 * 180.0f + 20;
|
||||
} else {
|
||||
if (fabs(cx - near_x1) > fabs(cx - near_x2))
|
||||
{
|
||||
dx_near = near_x2 - cx - 45;
|
||||
temp_near = dx_near;
|
||||
}
|
||||
if (fabs(cx - near_x1) < fabs(cx - near_x2))
|
||||
{
|
||||
dx_near = near_x1 - cx + 45;
|
||||
temp_near = dx_near;
|
||||
}
|
||||
if (fabs(cx - near_x1) == fabs(cx - near_x2))
|
||||
{
|
||||
dx_near = 0;
|
||||
temp_near = dx_near;
|
||||
}
|
||||
|
||||
|
||||
//pure_angle = -atanf(PIXPERMETER * 2.0f * 0.2f * 0.5f * dx / dn) / PI32 * 180.0f;
|
||||
switch (barrier_type) {
|
||||
case BARRIER_LEFT_BEGIN:
|
||||
// dx_near = mid_track[aim_idx_near][1] - cx + barrier_offset;
|
||||
pure_angle = -atanf(PIXPERMETER * 2.0f * 0.2f * 0.5f * dx / dn) / PI32 * 180.0f;
|
||||
break;
|
||||
case BARRIER_RIGHT_BEGIN:
|
||||
pure_angle = -atanf(PIXPERMETER * 2.0f * 0.2f * 0.5f * dx / dn) / PI32 * 180.0f;
|
||||
default:
|
||||
// pure_angle = -atanf(PIXPERMETER * 2.0f * 0.2f * 0.5f * dx / dn) / PI32 * 180.0f;
|
||||
if (dy > 0) {
|
||||
pure_angle = -atanf(dx / dy) / PI32 * 180.0f;
|
||||
last_pure_angle = pure_angle;
|
||||
// last_pure_angle_half = pure_angle_half;
|
||||
} else {
|
||||
pure_angle = last_pure_angle;
|
||||
// pure_angle_half = last_pure_angle_half;
|
||||
}
|
||||
}
|
||||
if (garage_type == GARAGE_FOUND) {
|
||||
pure_angle = 0.f;
|
||||
}
|
||||
if (cross_type == CROSS_IN)
|
||||
{
|
||||
pure_angle = -atanf(dx / (dy / 2)) / PI32 * 180.0f;
|
||||
}
|
||||
|
||||
|
||||
// // 计算近锚点偏差值
|
||||
// dx_near = rptsn[aim_idx_near][1] - cx;
|
||||
// // float dy_near = cy - rptsn[aim_idx_near][0] + 0.2 * PIXPERMETER;
|
||||
// // float dn_near = Q_sqrt(dx_near * dx_near + dy_near * dy_near);
|
||||
// // float error_near = -atan2f(dx_near, dy_near) * 180 / PI32;
|
||||
|
||||
// // //考虑近点
|
||||
// // near_angle = -atanf(PIXPERMETER * 2 * 0.2 * dx_near / dn_near / dn_near) / PI32 * 180 ;
|
||||
// // //考虑远点
|
||||
// pure_angle = -atanf(PIXPERMETER * 2.0f * 0.2f * dx / dn / dn) / PI32 * 180.0f;
|
||||
}
|
||||
if (circle_type == CIRCLE_LEFT_IN || circle_type == CIRCLE_LEFT_OUT || circle_type == CIRCLE_RIGHT_IN || circle_type == CIRCLE_RIGHT_OUT || circle_type == CIRCLE_LEFT_RUNNING || circle_type == CIRCLE_RIGHT_RUNNING) {
|
||||
|
||||
if (circle_type == CIRCLE_LEFT_IN || circle_type == CIRCLE_RIGHT_IN || circle_type == CIRCLE_LEFT_BEGIN || circle_type == CIRCLE_RIGHT_BEGIN) {
|
||||
state_type = CIRCLE_STATE;
|
||||
timer_clear(TIM_3);
|
||||
timer_start(TIM_3);
|
||||
}
|
||||
if (circle_type == CIRCLE_LEFT_RUNNING || circle_type == CIRCLE_RIGHT_RUNNING || circle_type == CIRCLE_RIGHT_OUT || circle_type == CIRCLE_LEFT_OUT) {
|
||||
if (circle_flag == 1) {
|
||||
state_type = CIRCLE_STATE;
|
||||
}
|
||||
|
||||
uint16 ti = timer_get(TIM_3);
|
||||
if (ti >= 1000) {
|
||||
timer_stop(TIM_3);
|
||||
timer_clear(TIM_3);
|
||||
|
||||
circle_flag = 0;
|
||||
}
|
||||
if (circle_flag == 0) {
|
||||
state_type = CIRCLE_RUNNING_STATE;
|
||||
}
|
||||
}
|
||||
|
||||
if (circle_type == CIRCLE_NONE) {
|
||||
circle_flag = 1;
|
||||
}
|
||||
|
||||
if (circle_type == CIRCLE_LEFT_END || circle_type == CIRCLE_RIGHT_END) {
|
||||
state_type = STRAIGHT_STATE;
|
||||
}
|
||||
|
||||
if (barrier_type == BARRIER_LEFT_BEGIN || barrier_type == BARRIER_LEFT_RUNNING || barrier_type == BARRIER_RIGHT_BEGIN || barrier_type == BARRIER_RIGHT_RUNNING) {
|
||||
state_type = BARRIER_STATE;
|
||||
}
|
||||
|
||||
if (cross_type == CROSS_BEGIN || cross_type == CROSS_IN) {
|
||||
state_type = STRAIGHT_STATE;
|
||||
}
|
||||
|
||||
if (state_type == STRAIGHT_STATE) {
|
||||
aim_distance = straight_aim;
|
||||
} else if (state_type == TURN_STATE) {
|
||||
aim_distance = turn_aim;
|
||||
}
|
||||
if (cross_type == CROSS_IN)
|
||||
{
|
||||
aim_distance = cross_aim;
|
||||
}
|
||||
if (curvature >= turn_threshold)
|
||||
{
|
||||
aim_distance = turn_aim;
|
||||
}
|
||||
if (curvature <= turn_threshold)
|
||||
{
|
||||
aim_distance = mid_aim;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (garage_type == GARAGE_FOUND) {
|
||||
last_garage_type = GARAGE_FOUND;
|
||||
}
|
||||
|
||||
if (last_garage_type == GARAGE_FOUND) {
|
||||
pingbi_num++;
|
||||
if (pingbi_num >= 300)
|
||||
{
|
||||
pingbi_num = 300;
|
||||
}
|
||||
|
||||
if (pingbi_num >= 100) {
|
||||
if (state_type != BARRIER_STATE || garage_type != GARAGE_FOUND) {
|
||||
if ((pts_left_count <= 2) && (pts_right_count <= 2) && (GET_PIX_1C(mt9v03x_image_copy[0], BEGINH_L, IMAGE_W / 2 - BEGINW_R) <= FIX_BINTHRESHOLD) && (GET_PIX_1C(mt9v03x_image_copy[0], BEGINH_L, IMAGE_W / 2 + BEGINW_L) <= FIX_BINTHRESHOLD)) {
|
||||
garage_type = OUT_STOP;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (garage_type == OUT_STOP)
|
||||
{
|
||||
garage_type = GARAGE_FOUND;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (state_type != BARRIER_STATE || garage_type != GARAGE_FOUND) {
|
||||
if ((pts_left_count <= 2) && (pts_right_count <= 2) && (GET_PIX_1C(mt9v03x_image_copy[0], BEGINH_L, IMAGE_W / 2 - BEGINW_R) <= FIX_BINTHRESHOLD) && (GET_PIX_1C(mt9v03x_image_copy[0], BEGINH_L, IMAGE_W / 2 + BEGINW_L) <= FIX_BINTHRESHOLD)) {
|
||||
garage_type = OUT_STOP;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,13 @@
|
||||
extern float (*mid_track)[2];
|
||||
extern int32_t mid_track_count;
|
||||
extern float pure_angle;
|
||||
extern float pure_angle_half;
|
||||
extern float dx_near;
|
||||
extern float curvature;
|
||||
|
||||
extern int8_t turn_flag ;
|
||||
extern float curvature;
|
||||
extern float turn_threshold;
|
||||
void aim_distance_select(void);
|
||||
void tracking(void);
|
||||
void ElementJudge(void);
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
********************************************************************************************************************/
|
||||
|
||||
#include "zf_common_headfile.h"
|
||||
#include "gl_headfile.h"
|
||||
#include "by_button.h"
|
||||
#include "by_buzzer.h"
|
||||
#include "by_frame.h"
|
||||
@@ -92,11 +93,11 @@ void USART1_IRQHandler(void)
|
||||
void USART2_IRQHandler(void)
|
||||
{
|
||||
if (USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) {
|
||||
by_frame_parse_uart_handle((uint8_t)USART_ReceiveData(USART2));
|
||||
USART_ClearITPendingBit(USART2, USART_IT_RXNE);
|
||||
}
|
||||
|
||||
if (USART_GetFlagStatus(USART2, USART_FLAG_ORE) != RESET) {
|
||||
|
||||
USART_ClearFlag(USART2, USART_FLAG_ORE); // <20><><EFBFBD><EFBFBD> ORE <20><>־λ
|
||||
USART_ReceiveData(USART2);
|
||||
}
|
||||
@@ -285,8 +286,8 @@ void EXTI15_10_IRQHandler(void)
|
||||
void TIM1_UP_IRQHandler(void)
|
||||
{
|
||||
if (TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET) {
|
||||
by_frame_send(&tiny_frame_param[0].u32);
|
||||
TIM_ClearITPendingBit(TIM1, TIM_IT_Update);
|
||||
by_frame_send(&tiny_frame_param[0].u32);
|
||||
by_led_warn_blink();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,14 @@
|
||||
#include "./page/page.h"
|
||||
#include "gl_tracking.h"
|
||||
#include "gl_state.h"
|
||||
#include "gl_data.h"
|
||||
#include "zf_common_headfile.h"
|
||||
PARAM_INFO Param_Data[DATA_NUM];
|
||||
soft_iic_info_struct eeprom_param;
|
||||
TYPE_UNION iic_buffer[DATA_IN_FLASH_NUM];
|
||||
TYPE_UNION tiny_frame_param[20];
|
||||
uint32_t *addre[2];
|
||||
float auto_exp;
|
||||
/**
|
||||
* @brief 参数初始化注册
|
||||
*
|
||||
@@ -20,10 +22,16 @@ void jj_param_eeprom_init(void)
|
||||
PARAM_REG(aim_cricle, &cricle_aim, EFLOAT, 1, "cric:"); // 注冊
|
||||
PARAM_REG(aim_common, &common_aim, EFLOAT, 1, "comm:"); // 注冊
|
||||
PARAM_REG(aim_barrier, &barrier_aim, EFLOAT, 1, "barr:");
|
||||
PARAM_REG(aim_mid, &mid_aim, EFLOAT, 1, "mid:");
|
||||
PARAM_REG(offset_barrier, &barrier_offset, EFLOAT, 1, "offs:");
|
||||
PARAM_REG(delta_x, &pure_angle, EFLOAT, 2, "far:");
|
||||
PARAM_REG(delta_y, &dx_near, EFLOAT, 2, "near:");
|
||||
|
||||
PARAM_REG(delta_y, &curvature, EFLOAT, 2, "cur:");
|
||||
PARAM_REG(aim_straight, &straight_aim, EFLOAT, 1, "str:");
|
||||
PARAM_REG(aim_turn, &turn_aim, EFLOAT, 1, "tur:");
|
||||
PARAM_REG(baoguang, &FIX_BINTHRESHOLD, EFLOAT, 1, "bao:");
|
||||
PARAM_REG(auto_exp_param, &auto_exp, EFLOAT, 1, "exp:");
|
||||
PARAM_REG(barr_time, &barrirer_time, EFLOAT, 1, "bar:");
|
||||
PARAM_REG(cross_sw, &cross_open, EFLOAT, 1, "cro_sw:");
|
||||
jj_param_read(); // 注冊
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -23,12 +23,15 @@ typedef enum {
|
||||
aim_cricle,
|
||||
aim_barrier,
|
||||
offset_barrier,
|
||||
aim_straight,
|
||||
aim_turn,
|
||||
aim_mid,
|
||||
Page2_head,
|
||||
// 第二页参数
|
||||
imgax_Kp = Page2_head,
|
||||
imgax_Ki,
|
||||
imgax_Kd,
|
||||
|
||||
baoguang = Page2_head,
|
||||
auto_exp_param,
|
||||
barr_time,
|
||||
cross_sw,
|
||||
Page3_head,
|
||||
DATA_IN_FLASH_NUM,
|
||||
|
||||
@@ -64,4 +67,5 @@ void jj_param_eeprom_init(void);
|
||||
void jj_param_write(void);
|
||||
void jj_param_read(void);
|
||||
extern float data7;
|
||||
extern float auto_exp;
|
||||
#endif
|
||||
25
app/main.c
25
app/main.c
@@ -29,14 +29,15 @@
|
||||
#include "by_led.h"
|
||||
#include "jj_param.h"
|
||||
#include "jj_blueteeth.h"
|
||||
#include "zf_device_config.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
TYPE_UNION recv_data[BY_FRAME_DATA_NUM_RECV];
|
||||
clock_init(SYSTEM_CLOCK_144M);
|
||||
system_delay_init();
|
||||
debug_init();
|
||||
mt9v03x_init();
|
||||
|
||||
ips200_init(IPS200_TYPE_SPI);
|
||||
|
||||
by_led_init();
|
||||
@@ -46,18 +47,30 @@ int main(void)
|
||||
jj_bt_init();
|
||||
jj_param_eeprom_init();
|
||||
|
||||
mt9v03x_init();
|
||||
mt9v03x_sccb_set_exposure_time((uint16_t)auto_exp);
|
||||
|
||||
Page_Init();
|
||||
|
||||
pit_ms_init(TIM1_PIT, 10);
|
||||
timer_init(TIM_3, TIMER_MS);
|
||||
timer_init(TIM_2, TIMER_MS);
|
||||
by_frame_init();
|
||||
|
||||
printf("start running\r\n");
|
||||
while (1) {
|
||||
memset(recv_data, 0, sizeof(recv_data));
|
||||
by_frame_parse(&recv_data[0].u32);
|
||||
if (0x0D == recv_data[0].u32) {
|
||||
NVIC_SystemReset();
|
||||
} else if (0x5C == recv_data[0].u32) {
|
||||
begin_flag = 1;
|
||||
}
|
||||
|
||||
Page_Run();
|
||||
by_buzzer_run();
|
||||
tiny_frame_param[0].f32 = pure_angle;
|
||||
tiny_frame_param[1].f32 = dx_near;
|
||||
tiny_frame_param[1].f32 = curvature;
|
||||
tiny_frame_param[2].u8[0] = (uint8_t)state_type; // 0: 无状态 1: 弯道 2: 直行
|
||||
tiny_frame_param[2].u8[1] = (uint8_t)garage_type; // 0: 无车库 1: 有车库
|
||||
if (mt9v03x_finish_flag) {
|
||||
@@ -68,12 +81,14 @@ int main(void)
|
||||
state_type = COMMON_STATE;
|
||||
img_processing();
|
||||
get_corners();
|
||||
aim_distance_select();
|
||||
tracking();
|
||||
ElementJudge();
|
||||
ElementRun();
|
||||
aim_distance_select();
|
||||
MidLineTrack();
|
||||
bt_printf("type= %d", circle_type);
|
||||
// if (barrier_type) {
|
||||
// bt_printf("type= %d", barrier_type);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ void Page_Init(void)
|
||||
PAGE_REG(page_menu, "main");
|
||||
PAGE_REG(page_rtcam, "rtcam");
|
||||
PAGE_REG(page_param1, "aim_param");
|
||||
PAGE_REG(page_param2, "param2");
|
||||
PAGE_REG(page_param2, "exp");
|
||||
PAGE_REG(page_dparam, "dparam");
|
||||
PAGE_REG(page_reset, "reset");
|
||||
// PAGE_REG(page_argv);
|
||||
|
||||
@@ -49,11 +49,15 @@ static void Loop()
|
||||
{
|
||||
// 刷新参数数值
|
||||
ips200_show_float(90, 18 + 2, *((float *)(Param_Data[delta_x].p_data)), 4, 5);
|
||||
ips200_show_float(90, 18 + 20, *((float *)(Param_Data[delta_y].p_data)), 4, 5);
|
||||
ips200_show_float(90, 18 + 20, FIX_BINTHRESHOLD, 4, 5);
|
||||
ips200_show_int(90, 18 + 38, track_type, 1);
|
||||
ips200_show_int(90, 18 + 56, garage_type, 1);
|
||||
ips200_show_int(90, 18 + 74, cross_type, 1);
|
||||
ips200_show_int(90, 18 + 92, circle_type, 1);
|
||||
ips200_show_int(90, 18 + 92, circle_type, 2);
|
||||
ips200_show_int(90, 18 + 110, s_type, 1);
|
||||
ips200_show_float(90, 18 + 128, curvature, 4, 5);
|
||||
ips200_show_int(90, 18 + 146, Lpt0_found_barrier_in, 1);
|
||||
ips200_show_int(90, 18 + 164, Lpt1_found_barrier_in, 1);
|
||||
}
|
||||
/**
|
||||
* @brief 页面事件
|
||||
|
||||
@@ -63,6 +63,7 @@ static void Loop()
|
||||
ips200_show_uint(160, 224, Lpt1_found_barrier_in, 3);
|
||||
ips200_show_uint(200, 165, barrier_type, 3);
|
||||
ips200_show_uint(200, 185, state_type, 5);
|
||||
//ips200_show_uint(200, 205, ceshi, 5);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,7 @@ static void Setup()
|
||||
} else if (Get_new_page() == page_param2) {
|
||||
pafrist = Page2_head;
|
||||
paend = Page3_head;
|
||||
ips200_show_string(0, 0, "Param2");
|
||||
ips200_show_string(0, 0, "exp");
|
||||
}
|
||||
|
||||
palong = paend - pafrist;
|
||||
@@ -102,7 +102,7 @@ static void Event(page_event event)
|
||||
}
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
} else if (1 == event_flag) {
|
||||
if (page_event_forward == event) {
|
||||
if (page_event_backward == event) {
|
||||
switch (Param_Data[Curser + pafrist - 1].type) {
|
||||
case EFLOAT:
|
||||
*((float *)(Param_Data[Curser + pafrist - 1].p_data)) += powf(10, index_power);
|
||||
@@ -116,7 +116,7 @@ static void Event(page_event event)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (page_event_backward == event) {
|
||||
} else if ( page_event_forward== event) {
|
||||
switch (Param_Data[Curser + pafrist - 1].type) {
|
||||
case EFLOAT:
|
||||
*((float *)(Param_Data[Curser + pafrist - 1].p_data)) -= powf(10.0f, (float)index_power);
|
||||
|
||||
@@ -33,7 +33,7 @@ static void Setup()
|
||||
} else if (Get_new_page() == page_param2) {
|
||||
pafrist = Page2_head;
|
||||
paend = Page3_head;
|
||||
ips200_show_string(0, 0, "Param2");
|
||||
ips200_show_string(0, 0, "exp");
|
||||
}
|
||||
|
||||
palong = paend - pafrist;
|
||||
@@ -45,11 +45,19 @@ static void Setup()
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
for (int16 i = 0; i < palong; i++) {
|
||||
ips200_show_string(20, i * 18 + 20, Param_Data[i + pafrist].text);
|
||||
if (Param_Data[i].type == EINT32)
|
||||
ips200_show_int(60, i * 18 + 20, *((int32 *)(Param_Data[i + pafrist].p_data)), 5);
|
||||
else if (Param_Data[i].type == EFLOAT)
|
||||
if (Param_Data[i+ pafrist].type == EINT32)
|
||||
{
|
||||
ips200_show_int(60, i * 18 + 20, *((int32_t *)(Param_Data[i + pafrist].p_data)), 5);
|
||||
}
|
||||
else if (Param_Data[i+ pafrist].type == EFLOAT)
|
||||
{
|
||||
ips200_show_float(60, i * 18 + 20, *((float *)(Param_Data[i + pafrist].p_data)), 4, 5);
|
||||
}
|
||||
else if (Param_Data[i+ pafrist].type == EUINT32)
|
||||
{
|
||||
ips200_show_uint(60, i * 18 + 20, *((uint32_t *)(Param_Data[i + pafrist].p_data)), 4);
|
||||
}
|
||||
}
|
||||
ips200_show_int(50, palong * 18 + 20, index_power, 5);
|
||||
}
|
||||
|
||||
@@ -92,6 +100,7 @@ static void Event(page_event event)
|
||||
return;
|
||||
} else if (page_event_press_long == event) {
|
||||
jj_param_write();
|
||||
mt9v03x_set_exposure_time(auto_exp);
|
||||
Page_Shift(page_menu);
|
||||
return;
|
||||
}
|
||||
@@ -102,21 +111,21 @@ static void Event(page_event event)
|
||||
}
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
} else if (1 == event_flag) {
|
||||
if (page_event_forward == event) {
|
||||
if (page_event_backward == event) {
|
||||
switch (Param_Data[Curser + pafrist - 1].type) {
|
||||
case EFLOAT:
|
||||
*((float *)(Param_Data[Curser + pafrist - 1].p_data)) += powf(10, index_power);
|
||||
*((float *)(Param_Data[Curser + pafrist - 1].p_data)) += powf(10.0f, (float)index_power);
|
||||
break;
|
||||
case EINT32:
|
||||
*((int32 *)(Param_Data[Curser + pafrist - 1].p_data)) += 1;
|
||||
break;
|
||||
case EUINT32:
|
||||
*((uint32 *)(Param_Data[Curser + pafrist - 1].p_data)) += 1;
|
||||
*((uint32 *)(Param_Data[Curser + pafrist - 1].p_data)) +=(uint32_t)powf(10, index_power);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (page_event_backward == event) {
|
||||
} else if ( page_event_forward == event) {
|
||||
switch (Param_Data[Curser + pafrist - 1].type) {
|
||||
case EFLOAT:
|
||||
*((float *)(Param_Data[Curser + pafrist - 1].p_data)) -= powf(10.0f, (float)index_power);
|
||||
@@ -125,14 +134,14 @@ static void Event(page_event event)
|
||||
*((int32 *)(Param_Data[Curser + pafrist - 1].p_data)) -= 1;
|
||||
break;
|
||||
case EUINT32:
|
||||
*((uint32 *)(Param_Data[Curser + pafrist - 1].p_data)) -= 1;
|
||||
*((uint32 *)(Param_Data[Curser + pafrist - 1].p_data)) -= (uint32_t)powf(10, index_power);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (page_event_press_short == event) {
|
||||
index_power++;
|
||||
if (index_power > 2) {
|
||||
if (index_power > 5) {
|
||||
index_power = -2;
|
||||
}
|
||||
ips200_show_int(50, palong * 18 + 20, index_power, 5);
|
||||
@@ -143,9 +152,9 @@ static void Event(page_event event)
|
||||
if (EINT32 == Param_Data[Curser + pafrist - 1].type)
|
||||
ips200_show_int(60, Curser * 18 + 2, *((int32 *)(Param_Data[Curser + pafrist - 1].p_data)), 5);
|
||||
else if (EUINT32 == Param_Data[Curser + pafrist - 1].type)
|
||||
ips200_show_uint(60, Curser * 18 + 2, *((int32 *)(Param_Data[Curser + pafrist - 1].p_data)), 5);
|
||||
ips200_show_uint(60, Curser * 18 + 2, *((uint32 *)(Param_Data[Curser + pafrist - 1].p_data)), 5);
|
||||
else if (EFLOAT == Param_Data[Curser + pafrist - 1].type)
|
||||
ips200_show_float(60, Curser * 18 + 2, *((float *)(Param_Data[Curser + pafrist - 1].p_data)), 4, 5);
|
||||
ips200_show_float(60, Curser * 18 + 2, *((float *)(Param_Data[Curser + pafrist - 1].p_data)), 8, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -171,10 +171,10 @@ void Show_Marked_Image(void)
|
||||
uint16_t mix_y = START_Y + (uint16_t)(rptsn[i][0] * vertical_zoom_rate);
|
||||
|
||||
// 近线数组显示
|
||||
if (i < pts_inv_l_count) {
|
||||
if (i < pts_resample_left_count) {
|
||||
ips200_draw_rect(l_x, l_y, l_x + 2, l_y + 1, RGB565_RED);
|
||||
}
|
||||
if (i < pts_inv_r_count) {
|
||||
if (i < pts_resample_right_count) {
|
||||
ips200_draw_rect(r_x - 2, r_y, r_x, r_y + 1, RGB565_BLUE);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
********************************************************************************************************************/
|
||||
|
||||
#include "zf_common_debug.h"
|
||||
|
||||
#include "zf_common_fifo.h"
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
@@ -81,33 +82,26 @@ static void fifo_end_offset (fifo_struct *fifo, uint32 offset)
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
fifo_state_enum fifo_clear (fifo_struct *fifo)
|
||||
{
|
||||
zf_assert(fifo != NULL);
|
||||
fifo_state_enum return_state = FIFO_SUCCESS;
|
||||
zf_assert(NULL != fifo);
|
||||
fifo_state_enum return_state = FIFO_SUCCESS; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
do
|
||||
{
|
||||
if(FIFO_CLEAR & fifo->execution)
|
||||
{
|
||||
return_state = FIFO_CLEAR_UNDO;
|
||||
break;
|
||||
}
|
||||
fifo->execution |= FIFO_CLEAR;
|
||||
fifo->head = 0;
|
||||
fifo->end = 0;
|
||||
fifo->size = fifo->max;
|
||||
// if(FIFO_IDLE != fifo->execution) // <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD>ǰ FIFO <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
// {
|
||||
// return_state = FIFO_RESET_UNDO; // <20><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
|
||||
// break;
|
||||
// }
|
||||
fifo->execution |= FIFO_RESET; // <20><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
fifo->head = 0; // <20><><EFBFBD><EFBFBD> FIFO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>λ
|
||||
fifo->end = 0; // <20><><EFBFBD><EFBFBD> FIFO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>λ
|
||||
fifo->size = fifo->max; // <20><><EFBFBD><EFBFBD> FIFO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>λ
|
||||
switch(fifo->type)
|
||||
{
|
||||
case FIFO_DATA_8BIT:
|
||||
memset(fifo->buffer, 0, fifo->max);
|
||||
break;
|
||||
case FIFO_DATA_16BIT:
|
||||
memset(fifo->buffer, 0, fifo->max * 2);
|
||||
break;
|
||||
case FIFO_DATA_32BIT:
|
||||
memset(fifo->buffer, 0, fifo->max * 4);
|
||||
break;
|
||||
case FIFO_DATA_8BIT: memset(fifo->buffer, 0, fifo->max); break;
|
||||
case FIFO_DATA_16BIT: memset(fifo->buffer, 0, fifo->max * 2); break;
|
||||
case FIFO_DATA_32BIT: memset(fifo->buffer, 0, fifo->max * 4); break;
|
||||
}
|
||||
// memset(fifo->buffer, 0, fifo->max);
|
||||
fifo->execution &= ~FIFO_CLEAR;
|
||||
fifo->execution = FIFO_IDLE; // <20><><EFBFBD><EFBFBD>״̬<D7B4><CCAC>λ
|
||||
}while(0);
|
||||
return return_state;
|
||||
}
|
||||
@@ -122,7 +116,7 @@ fifo_state_enum fifo_clear (fifo_struct *fifo)
|
||||
uint32 fifo_used (fifo_struct *fifo)
|
||||
{
|
||||
zf_assert(fifo != NULL);
|
||||
return (fifo->max - fifo->size);
|
||||
return (fifo->max - fifo->size); // <20><><EFBFBD>ص<EFBFBD>ǰ FIFO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD>
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
@@ -135,40 +129,34 @@ uint32 fifo_used (fifo_struct *fifo)
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
fifo_state_enum fifo_write_element (fifo_struct *fifo, uint32 dat)
|
||||
{
|
||||
zf_assert(fifo != NULL);
|
||||
fifo_state_enum return_state = FIFO_SUCCESS;
|
||||
zf_assert(NULL != fifo);
|
||||
fifo_state_enum return_state = FIFO_SUCCESS; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
|
||||
do
|
||||
{
|
||||
if(FIFO_WRITE & fifo->execution)
|
||||
if((FIFO_RESET | FIFO_WRITE) & fifo->execution) // <20><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ <20><><EFBFBD><EFBFBD>д<EFBFBD>뾺<EFBFBD><EBBEBA><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
return_state = FIFO_WRITE_UNDO;
|
||||
return_state = FIFO_WRITE_UNDO; // д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
|
||||
break;
|
||||
}
|
||||
fifo->execution |= FIFO_WRITE;
|
||||
fifo->execution |= FIFO_WRITE; // д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
|
||||
if(1 <= fifo->size) // ʣ<><CAA3><EFBFBD>ռ<EFBFBD><D5BC>㹻װ<E3B9BB>±<EFBFBD><C2B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
switch(fifo->type)
|
||||
{
|
||||
case FIFO_DATA_8BIT:
|
||||
((uint8 *)fifo->buffer)[fifo->head] = dat;
|
||||
break;
|
||||
case FIFO_DATA_16BIT:
|
||||
((uint16 *)fifo->buffer)[fifo->head] = dat;
|
||||
break;
|
||||
case FIFO_DATA_32BIT:
|
||||
((uint32 *)fifo->buffer)[fifo->head] = dat;
|
||||
break;
|
||||
case FIFO_DATA_8BIT: ((uint8 *)fifo->buffer)[fifo->head] = dat; break;
|
||||
case FIFO_DATA_16BIT: ((uint16 *)fifo->buffer)[fifo->head] = dat; break;
|
||||
case FIFO_DATA_32BIT: ((uint32 *)fifo->buffer)[fifo->head] = dat; break;
|
||||
}
|
||||
fifo_head_offset(fifo, 1); // ͷָ<CDB7><D6B8>ƫ<EFBFBD><C6AB>
|
||||
fifo->size -= 1; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><EFBFBD>ȼ<EFBFBD>С
|
||||
}
|
||||
else
|
||||
{
|
||||
return_state = FIFO_SPACE_NO_ENOUGH;
|
||||
return_state = FIFO_SPACE_NO_ENOUGH; // <20><>ǰ FIFO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ؿռ䲻<D5BC><E4B2BB>
|
||||
}
|
||||
fifo->execution &= ~FIFO_WRITE;
|
||||
fifo->execution &= ~FIFO_WRITE; // д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
}while(0);
|
||||
|
||||
return return_state;
|
||||
@@ -185,23 +173,23 @@ fifo_state_enum fifo_write_element (fifo_struct *fifo, uint32 dat)
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
fifo_state_enum fifo_write_buffer (fifo_struct *fifo, void *dat, uint32 length)
|
||||
{
|
||||
zf_assert(fifo != NULL);
|
||||
fifo_state_enum return_state = FIFO_SUCCESS;
|
||||
zf_assert(NULL != fifo);
|
||||
fifo_state_enum return_state = FIFO_SUCCESS; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
uint32 temp_length = 0;
|
||||
|
||||
do
|
||||
{
|
||||
if(NULL == dat)
|
||||
{
|
||||
return_state = FIFO_BUFFER_NULL;
|
||||
return_state = FIFO_BUFFER_NULL; // <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣
|
||||
break;
|
||||
}
|
||||
if(FIFO_WRITE & fifo->execution)
|
||||
if((FIFO_RESET | FIFO_WRITE) & fifo->execution) // <20><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ <20><><EFBFBD><EFBFBD>д<EFBFBD>뾺<EFBFBD><EBBEBA><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
return_state = FIFO_WRITE_UNDO;
|
||||
return_state = FIFO_WRITE_UNDO; // д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
|
||||
break;
|
||||
}
|
||||
fifo->execution |= FIFO_WRITE;
|
||||
fifo->execution |= FIFO_WRITE; // д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
|
||||
if(length <= fifo->size) // ʣ<><CAA3><EFBFBD>ռ<EFBFBD><D5BC>㹻װ<E3B9BB>±<EFBFBD><C2B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
@@ -212,6 +200,7 @@ fifo_state_enum fifo_write_buffer (fifo_struct *fifo, void *dat, uint32 length)
|
||||
switch(fifo->type)
|
||||
{
|
||||
case FIFO_DATA_8BIT:
|
||||
{
|
||||
memcpy(
|
||||
&(((uint8 *)fifo->buffer)[fifo->head]),
|
||||
dat, temp_length); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
@@ -221,8 +210,9 @@ fifo_state_enum fifo_write_buffer (fifo_struct *fifo, void *dat, uint32 length)
|
||||
&(((uint8 *)dat)[temp_length]),
|
||||
length - temp_length); // <20><><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
fifo_head_offset(fifo, length - temp_length); // ͷָ<CDB7><D6B8>ƫ<EFBFBD><C6AB>
|
||||
break;
|
||||
}break;
|
||||
case FIFO_DATA_16BIT:
|
||||
{
|
||||
memcpy(
|
||||
&(((uint16 *)fifo->buffer)[fifo->head]),
|
||||
dat, temp_length * 2); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
@@ -232,8 +222,9 @@ fifo_state_enum fifo_write_buffer (fifo_struct *fifo, void *dat, uint32 length)
|
||||
&(((uint16 *)dat)[temp_length]),
|
||||
(length - temp_length) * 2); // <20><><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
fifo_head_offset(fifo, length - temp_length); // ͷָ<CDB7><D6B8>ƫ<EFBFBD><C6AB>
|
||||
break;
|
||||
}break;
|
||||
case FIFO_DATA_32BIT:
|
||||
{
|
||||
memcpy(
|
||||
&(((uint32 *)fifo->buffer)[fifo->head]),
|
||||
dat, temp_length * 4); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
@@ -243,7 +234,7 @@ fifo_state_enum fifo_write_buffer (fifo_struct *fifo, void *dat, uint32 length)
|
||||
&(((uint32 *)dat)[temp_length]),
|
||||
(length - temp_length) * 4); // <20><><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
fifo_head_offset(fifo, length - temp_length); // ͷָ<CDB7><D6B8>ƫ<EFBFBD><C6AB>
|
||||
break;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -251,35 +242,36 @@ fifo_state_enum fifo_write_buffer (fifo_struct *fifo, void *dat, uint32 length)
|
||||
switch(fifo->type)
|
||||
{
|
||||
case FIFO_DATA_8BIT:
|
||||
{
|
||||
memcpy(
|
||||
&(((uint8 *)fifo->buffer)[fifo->head]),
|
||||
dat, length); // һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>
|
||||
fifo_head_offset(fifo, length); // ͷָ<CDB7><D6B8>ƫ<EFBFBD><C6AB>
|
||||
break;
|
||||
}break;
|
||||
case FIFO_DATA_16BIT:
|
||||
{
|
||||
memcpy(
|
||||
&(((uint16 *)fifo->buffer)[fifo->head]),
|
||||
dat, length * 2); // һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>
|
||||
fifo_head_offset(fifo, length); // ͷָ<CDB7><D6B8>ƫ<EFBFBD><C6AB>
|
||||
break;
|
||||
}break;
|
||||
case FIFO_DATA_32BIT:
|
||||
{
|
||||
memcpy(
|
||||
&(((uint32 *)fifo->buffer)[fifo->head]),
|
||||
dat, length * 4); // һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>
|
||||
fifo_head_offset(fifo, length); // ͷָ<CDB7><D6B8>ƫ<EFBFBD><C6AB>
|
||||
break;
|
||||
}break;
|
||||
}
|
||||
// memcpy(&fifo->buffer[fifo->head], dat, length); // һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>
|
||||
// fifo_head_offset(fifo, length); // ͷָ<CDB7><D6B8>ƫ<EFBFBD><C6AB>
|
||||
}
|
||||
|
||||
fifo->size -= length; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><EFBFBD>ȼ<EFBFBD>С
|
||||
}
|
||||
else
|
||||
{
|
||||
return_state = FIFO_SPACE_NO_ENOUGH;
|
||||
return_state = FIFO_SPACE_NO_ENOUGH; // <20><>ǰ FIFO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ؿռ䲻<D5BC><E4B2BB>
|
||||
}
|
||||
fifo->execution &= ~FIFO_WRITE;
|
||||
fifo->execution &= ~FIFO_WRITE; // д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
}while(0);
|
||||
|
||||
return return_state;
|
||||
@@ -296,50 +288,52 @@ fifo_state_enum fifo_write_buffer (fifo_struct *fifo, void *dat, uint32 length)
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
fifo_state_enum fifo_read_element (fifo_struct *fifo, void *dat, fifo_operation_enum flag)
|
||||
{
|
||||
zf_assert(fifo != NULL);
|
||||
fifo_state_enum return_state = FIFO_SUCCESS;
|
||||
zf_assert(NULL != fifo);
|
||||
fifo_state_enum return_state = FIFO_SUCCESS; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
|
||||
do
|
||||
{
|
||||
if(NULL == dat)
|
||||
{
|
||||
return_state = FIFO_BUFFER_NULL;
|
||||
return_state = FIFO_BUFFER_NULL; // <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣
|
||||
}
|
||||
else
|
||||
{
|
||||
if((FIFO_RESET | FIFO_CLEAR) & fifo->execution) // <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD>ǰ FIFO <20>Ƿ<EFBFBD><C7B7><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>
|
||||
{
|
||||
return_state = FIFO_READ_UNDO; // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
|
||||
break;
|
||||
}
|
||||
fifo->execution |= FIFO_READ;
|
||||
|
||||
if(1 > fifo_used(fifo))
|
||||
{
|
||||
return_state = FIFO_DATA_NO_ENOUGH; // <20><>־<EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><EFBFBD><EFBFBD>
|
||||
return_state = FIFO_DATA_NO_ENOUGH; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3>Ȳ<EFBFBD><EFBFBD><EFBFBD>
|
||||
break; // ֱ<><D6B1><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
fifo->execution |= FIFO_READ; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
switch(fifo->type)
|
||||
{
|
||||
case FIFO_DATA_8BIT:
|
||||
*((uint8 *)dat) = ((uint8 *)fifo->buffer)[fifo->end];
|
||||
break;
|
||||
case FIFO_DATA_16BIT:
|
||||
*((uint16 *)dat) = ((uint16 *)fifo->buffer)[fifo->end];
|
||||
break;
|
||||
case FIFO_DATA_32BIT:
|
||||
*((uint32 *)dat) = ((uint32 *)fifo->buffer)[fifo->end];
|
||||
break;
|
||||
case FIFO_DATA_8BIT: *((uint8 *)dat) = ((uint8 *)fifo->buffer)[fifo->end]; break;
|
||||
case FIFO_DATA_16BIT: *((uint16 *)dat) = ((uint16 *)fifo->buffer)[fifo->end]; break;
|
||||
case FIFO_DATA_32BIT: *((uint32 *)dat) = ((uint32 *)fifo->buffer)[fifo->end]; break;
|
||||
}
|
||||
fifo->execution &= ~FIFO_READ; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
}
|
||||
|
||||
if(flag == FIFO_READ_AND_CLEAN) // <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FIFO ״̬
|
||||
if(FIFO_READ_AND_CLEAN == flag) // <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FIFO ״̬
|
||||
{
|
||||
if(FIFO_CLEAR & fifo->execution)
|
||||
if((FIFO_RESET | FIFO_CLEAR | FIFO_READ) == fifo->execution) // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ȡ ״̬ <20><><EFBFBD><EFBFBD><EFBFBD>쳣
|
||||
{
|
||||
return_state = FIFO_CLEAR_UNDO;
|
||||
return_state = FIFO_CLEAR_UNDO; // <20><><EFBFBD>ղ<EFBFBD><D5B2><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
|
||||
break;
|
||||
}
|
||||
fifo->execution |= FIFO_CLEAR;
|
||||
fifo->execution |= FIFO_CLEAR; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
fifo_end_offset(fifo, 1); // <20>ƶ<EFBFBD> FIFO ͷָ<CDB7><D6B8>
|
||||
fifo->size += 1;
|
||||
fifo->execution &= ~FIFO_CLEAR;
|
||||
fifo->size += 1; // <20>ͷŶ<CDB7>Ӧ<EFBFBD><D3A6><EFBFBD>ȿռ<C8BF>
|
||||
fifo->execution &= ~FIFO_CLEAR; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
}
|
||||
}while(0);
|
||||
fifo->execution &= FIFO_READ;
|
||||
|
||||
return return_state;
|
||||
}
|
||||
@@ -356,43 +350,48 @@ fifo_state_enum fifo_read_element (fifo_struct *fifo, void *dat, fifo_operation_
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
fifo_state_enum fifo_read_buffer (fifo_struct *fifo, void *dat, uint32 *length, fifo_operation_enum flag)
|
||||
{
|
||||
zf_assert(fifo != NULL);
|
||||
zf_assert(length != NULL);
|
||||
fifo_state_enum return_state = FIFO_SUCCESS;
|
||||
uint32 temp_length;
|
||||
uint32 fifo_data_length;
|
||||
zf_assert(NULL != fifo);
|
||||
zf_assert(NULL != length);
|
||||
fifo_state_enum return_state = FIFO_SUCCESS; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
uint32 temp_length = 0;
|
||||
uint32 fifo_data_length = 0;
|
||||
|
||||
do
|
||||
{
|
||||
if(NULL == dat)
|
||||
{
|
||||
return_state = FIFO_BUFFER_NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((FIFO_RESET | FIFO_CLEAR) & fifo->execution) // <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD>ǰ FIFO <20>Ƿ<EFBFBD><C7B7><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>
|
||||
{
|
||||
*length = fifo_data_length; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ij<EFBFBD><C4B3><EFBFBD>
|
||||
return_state = FIFO_READ_UNDO; // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
|
||||
break;
|
||||
}
|
||||
fifo->execution |= FIFO_READ;
|
||||
|
||||
fifo_data_length = fifo_used(fifo);
|
||||
|
||||
if(*length > fifo_data_length)
|
||||
fifo_data_length = fifo_used(fifo); // <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD>
|
||||
if(*length > fifo_data_length) // <20>жϳ<D0B6><CFB3><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>㹻
|
||||
{
|
||||
*length = fifo_data_length; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ij<EFBFBD><C4B3><EFBFBD>
|
||||
return_state = FIFO_DATA_NO_ENOUGH; // <20><>־<EFBFBD><D6BE><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD>
|
||||
if(0 == fifo_data_length) // <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ֱ<EFBFBD><D6B1><EFBFBD>˳<EFBFBD>
|
||||
{
|
||||
fifo->execution &= ~FIFO_READ; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fifo->execution |= FIFO_READ; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
temp_length = fifo->max - fifo->end; // <20><><EFBFBD><EFBFBD>βָ<CEB2><D6B8><EFBFBD><EFBFBD><EFBFBD>뻺<EFBFBD><EBBBBA><EFBFBD><EFBFBD>β<EFBFBD><CEB2><EFBFBD>ж<EFBFBD><D0B6>ٿռ<D9BF>
|
||||
if(*length <= temp_length) // <20>㹻һ<E3B9BB><D2BB><EFBFBD>Զ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
||||
{
|
||||
switch(fifo->type)
|
||||
{
|
||||
case FIFO_DATA_8BIT:
|
||||
memcpy(dat, &(((uint8 *)fifo->buffer)[fifo->end]), *length);
|
||||
break;
|
||||
case FIFO_DATA_16BIT:
|
||||
memcpy(dat, &(((uint16 *)fifo->buffer)[fifo->end]), *length * 2);
|
||||
break;
|
||||
case FIFO_DATA_32BIT:
|
||||
memcpy(dat, &(((uint32 *)fifo->buffer)[fifo->end]), *length * 4);
|
||||
break;
|
||||
case FIFO_DATA_8BIT: memcpy(dat, &(((uint8 *)fifo->buffer)[fifo->end]), *length); break;
|
||||
case FIFO_DATA_16BIT: memcpy(dat, &(((uint16 *)fifo->buffer)[fifo->end]), *length * 2); break;
|
||||
case FIFO_DATA_32BIT: memcpy(dat, &(((uint32 *)fifo->buffer)[fifo->end]), *length * 4); break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -400,34 +399,38 @@ fifo_state_enum fifo_read_buffer (fifo_struct *fifo, void *dat, uint32 *length,
|
||||
switch(fifo->type)
|
||||
{
|
||||
case FIFO_DATA_8BIT:
|
||||
{
|
||||
memcpy(dat, &(((uint8 *)fifo->buffer)[fifo->end]), temp_length);
|
||||
memcpy(&(((uint8 *)dat)[temp_length]), fifo->buffer, *length - temp_length);
|
||||
break;
|
||||
}break;
|
||||
case FIFO_DATA_16BIT:
|
||||
{
|
||||
memcpy(dat, &(((uint16 *)fifo->buffer)[fifo->end]), temp_length * 2);
|
||||
memcpy(&(((uint16 *)dat)[temp_length]), fifo->buffer, (*length - temp_length) * 2);
|
||||
break;
|
||||
}break;
|
||||
case FIFO_DATA_32BIT:
|
||||
{
|
||||
memcpy(dat, &(((uint32 *)fifo->buffer)[fifo->end]), temp_length * 4);
|
||||
memcpy(&(((uint32 *)dat)[temp_length]), fifo->buffer, (*length - temp_length) * 4);
|
||||
break;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
fifo->execution &= ~FIFO_READ; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
}
|
||||
|
||||
if(flag == FIFO_READ_AND_CLEAN) // <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FIFO ״̬
|
||||
if(FIFO_READ_AND_CLEAN == flag) // <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FIFO ״̬
|
||||
{
|
||||
if(FIFO_CLEAR & fifo->execution)
|
||||
if((FIFO_RESET | FIFO_CLEAR | FIFO_READ) == fifo->execution) // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ȡ ״̬ <20><><EFBFBD><EFBFBD><EFBFBD>쳣
|
||||
{
|
||||
return_state = FIFO_CLEAR_UNDO;
|
||||
return_state = FIFO_CLEAR_UNDO; // <20><><EFBFBD>ղ<EFBFBD><D5B2><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
|
||||
break;
|
||||
}
|
||||
fifo->execution |= FIFO_CLEAR;
|
||||
fifo->execution |= FIFO_CLEAR; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
fifo_end_offset(fifo, *length); // <20>ƶ<EFBFBD> FIFO ͷָ<CDB7><D6B8>
|
||||
fifo->size += *length;
|
||||
fifo->execution &= ~FIFO_CLEAR;
|
||||
fifo->size += *length; // <20>ͷŶ<CDB7>Ӧ<EFBFBD><D3A6><EFBFBD>ȿռ<C8BF>
|
||||
fifo->execution &= ~FIFO_CLEAR; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
}
|
||||
}while(0);
|
||||
fifo->execution &= FIFO_READ;
|
||||
|
||||
return return_state;
|
||||
}
|
||||
@@ -446,41 +449,47 @@ fifo_state_enum fifo_read_buffer (fifo_struct *fifo, void *dat, uint32 *length,
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
fifo_state_enum fifo_read_tail_buffer (fifo_struct *fifo, void *dat, uint32 *length, fifo_operation_enum flag)
|
||||
{
|
||||
zf_assert(fifo != NULL);
|
||||
zf_assert(length != NULL);
|
||||
fifo_state_enum return_state = FIFO_SUCCESS;
|
||||
uint32 temp_length;
|
||||
uint32 fifo_data_length;
|
||||
zf_assert(NULL != fifo);
|
||||
zf_assert(NULL != length);
|
||||
fifo_state_enum return_state = FIFO_SUCCESS; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
uint32 temp_length = 0;
|
||||
uint32 fifo_data_length = 0;
|
||||
|
||||
do
|
||||
{
|
||||
if(NULL == dat)
|
||||
{
|
||||
return_state = FIFO_BUFFER_NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((FIFO_RESET | FIFO_CLEAR | FIFO_WRITE) & fifo->execution) // <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD>ǰ FIFO <20>Ƿ<EFBFBD><C7B7><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>
|
||||
{
|
||||
*length = fifo_data_length; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ij<EFBFBD><C4B3><EFBFBD>
|
||||
return_state = FIFO_READ_UNDO; // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
|
||||
break;
|
||||
}
|
||||
fifo->execution |= FIFO_READ;
|
||||
|
||||
fifo_data_length = fifo_used(fifo);
|
||||
if(*length > fifo_data_length)
|
||||
fifo_data_length = fifo_used(fifo); // <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD>
|
||||
if(*length > fifo_data_length) // <20>жϳ<D0B6><CFB3><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>㹻
|
||||
{
|
||||
*length = fifo_data_length; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ij<EFBFBD><C4B3><EFBFBD>
|
||||
return_state = FIFO_DATA_NO_ENOUGH; // <20><>־<EFBFBD><D6BE><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD>
|
||||
if(0 == fifo_data_length) // <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ֱ<EFBFBD><D6B1><EFBFBD>˳<EFBFBD>
|
||||
{
|
||||
fifo->execution &= ~FIFO_READ; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fifo->execution |= FIFO_READ; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
if((fifo->head > fifo->end) || (fifo->head >= *length))
|
||||
{
|
||||
switch(fifo->type)
|
||||
{
|
||||
case FIFO_DATA_8BIT:
|
||||
memcpy(dat, &(((uint8 *)fifo->buffer)[fifo->head - *length]), *length);
|
||||
break;
|
||||
case FIFO_DATA_16BIT:
|
||||
memcpy(dat, &(((uint16 *)fifo->buffer)[fifo->head - *length]), *length * 2);
|
||||
break;
|
||||
case FIFO_DATA_32BIT:
|
||||
memcpy(dat, &(((uint32 *)fifo->buffer)[fifo->head - *length]), *length * 4);
|
||||
break;
|
||||
case FIFO_DATA_8BIT: memcpy(dat, &(((uint8 *)fifo->buffer)[fifo->head - *length]), *length); break;
|
||||
case FIFO_DATA_16BIT: memcpy(dat, &(((uint16 *)fifo->buffer)[fifo->head - *length]), *length * 2);break;
|
||||
case FIFO_DATA_32BIT: memcpy(dat, &(((uint32 *)fifo->buffer)[fifo->head - *length]), *length * 4);break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -489,34 +498,35 @@ fifo_state_enum fifo_read_tail_buffer (fifo_struct *fifo, void *dat, uint32 *len
|
||||
switch(fifo->type)
|
||||
{
|
||||
case FIFO_DATA_8BIT:
|
||||
{
|
||||
memcpy(dat, &(((uint8 *)fifo->buffer)[fifo->max - temp_length]), temp_length);
|
||||
memcpy(&(((uint8 *)dat)[temp_length]), &(((uint8 *)fifo->buffer)[fifo->head - *length]), (*length - temp_length));
|
||||
break;
|
||||
}break;
|
||||
case FIFO_DATA_16BIT:
|
||||
{
|
||||
memcpy(dat, &(((uint16 *)fifo->buffer)[fifo->max - temp_length]), temp_length * 2);
|
||||
memcpy(&(((uint16 *)dat)[temp_length]), &(((uint16 *)fifo->buffer)[fifo->head - *length]), (*length - temp_length) * 2);
|
||||
break;
|
||||
}break;
|
||||
case FIFO_DATA_32BIT:
|
||||
{
|
||||
memcpy(dat, &(((uint32 *)fifo->buffer)[fifo->max - temp_length]), temp_length * 4);
|
||||
memcpy(&(((uint32 *)dat)[temp_length]), &(((uint32 *)fifo->buffer)[fifo->head - *length]), (*length - temp_length) * 4);
|
||||
break;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
fifo->execution &= ~FIFO_READ; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
}
|
||||
|
||||
if(flag == FIFO_READ_AND_CLEAN) // <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FIFO ״̬
|
||||
if(FIFO_READ_AND_CLEAN == flag) // <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FIFO ״̬
|
||||
{
|
||||
if(FIFO_CLEAR & fifo->execution)
|
||||
if((FIFO_RESET | FIFO_CLEAR | FIFO_READ) == fifo->execution) // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ȡ ״̬ <20><><EFBFBD><EFBFBD><EFBFBD>쳣
|
||||
{
|
||||
return_state = FIFO_CLEAR_UNDO;
|
||||
return_state = FIFO_CLEAR_UNDO; // <20><><EFBFBD>ղ<EFBFBD><D5B2><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
|
||||
break;
|
||||
}
|
||||
fifo->execution |= FIFO_CLEAR;
|
||||
fifo_end_offset(fifo, (fifo->max - fifo->size));
|
||||
fifo->size = fifo->max;
|
||||
fifo->execution &= ~FIFO_CLEAR;
|
||||
fifo_clear(fifo);
|
||||
}
|
||||
}while(0);
|
||||
fifo->execution &= FIFO_READ;
|
||||
|
||||
return return_state;
|
||||
}
|
||||
@@ -533,15 +543,10 @@ fifo_state_enum fifo_read_tail_buffer (fifo_struct *fifo, void *dat, uint32 *len
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
fifo_state_enum fifo_init (fifo_struct *fifo, fifo_data_type_enum type, void *buffer_addr, uint32 size)
|
||||
{
|
||||
zf_assert(fifo != NULL);
|
||||
fifo_state_enum return_value = FIFO_SUCCESS;
|
||||
zf_assert(NULL != fifo);
|
||||
fifo_state_enum return_state = FIFO_SUCCESS;
|
||||
do
|
||||
{
|
||||
if(NULL == buffer_addr)
|
||||
{
|
||||
return_value = FIFO_BUFFER_NULL;
|
||||
break;
|
||||
}
|
||||
fifo->buffer = buffer_addr;
|
||||
fifo->execution = FIFO_IDLE;
|
||||
fifo->type = type;
|
||||
@@ -550,5 +555,5 @@ fifo_state_enum fifo_init (fifo_struct *fifo, fifo_data_type_enum type, void *bu
|
||||
fifo->size = size;
|
||||
fifo->max = size;
|
||||
}while(0);
|
||||
return return_value;
|
||||
return return_state;
|
||||
}
|
||||
|
||||
@@ -40,37 +40,48 @@
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FIFO_SUCCESS,
|
||||
FIFO_SUCCESS, // FIFO <20><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>
|
||||
|
||||
FIFO_WRITE_UNDO,
|
||||
FIFO_CLEAR_UNDO,
|
||||
FIFO_BUFFER_NULL,
|
||||
FIFO_SPACE_NO_ENOUGH,
|
||||
FIFO_DATA_NO_ENOUGH,
|
||||
}fifo_state_enum;
|
||||
FIFO_RESET_UNDO, // FIFO <20><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>δִ<CEB4><D6B4>
|
||||
FIFO_CLEAR_UNDO, // FIFO <20><><EFBFBD>ղ<EFBFBD><D5B2><EFBFBD>δִ<CEB4><D6B4>
|
||||
FIFO_BUFFER_NULL, // FIFO <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣
|
||||
FIFO_WRITE_UNDO, // FIFO д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δִ<CEB4><D6B4>
|
||||
FIFO_SPACE_NO_ENOUGH, // FIFO д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ䲻<D5BC><E4B2BB>
|
||||
FIFO_READ_UNDO, // FIFO <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>δִ<CEB4><D6B4>
|
||||
FIFO_DATA_NO_ENOUGH, // FIFO <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD> <20><><EFBFBD>ݳ<EFBFBD><DDB3>Ȳ<EFBFBD><C8B2><EFBFBD>
|
||||
}fifo_state_enum; // FIFO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD> <20><><EFBFBD><EFBFBD>ǿ<EFBFBD><C7BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FIFO <20><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
|
||||
// <20><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
// ˳<><CBB3><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>պ<EFBFBD><D5BA><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
// β<><CEB2><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>պ<EFBFBD><D5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
// <20><>ȡ<EFBFBD><C8A1><EFBFBD>ղ<EFBFBD><D5B2><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>պ<EFBFBD><D5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD>˷<EFBFBD>ֹ<EFBFBD>ж<EFBFBD>Ƕ<EFBFBD><EFBFBD><D7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD>
|
||||
typedef enum
|
||||
{
|
||||
FIFO_IDLE = 0x00, // <20><><EFBFBD><EFBFBD>״̬
|
||||
|
||||
FIFO_RESET = 0x01, // <20><><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
||||
FIFO_CLEAR = 0x02, // <20><><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD><EFBFBD>
|
||||
FIFO_WRITE = 0x04, // <20><><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>д<EFBFBD>뻺<EFBFBD><EBBBBA><EFBFBD><EFBFBD>
|
||||
FIFO_READ = 0x08, // <20><><EFBFBD><EFBFBD>ִ<EFBFBD>ж<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}fifo_execution_enum; // FIFO <20><><EFBFBD><EFBFBD>״̬ ΪǶ<CEAA><C7B6>ʹ<EFBFBD><CAB9>Ԥ<EFBFBD><D4A4> <20><EFBFBD><DEB7><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FIFO_IDLE = 0x00,
|
||||
FIFO_CLEAR = 0x01,
|
||||
FIFO_WRITE = 0x02,
|
||||
FIFO_READ = 0x04,
|
||||
}fifo_execution_enum;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FIFO_READ_AND_CLEAN,
|
||||
FIFO_READ_ONLY,
|
||||
FIFO_READ_AND_CLEAN, // FIFO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷŶ<CDB7>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
FIFO_READ_ONLY, // FIFO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ <20><><EFBFBD><EFBFBD>ȡ
|
||||
}fifo_operation_enum;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FIFO_DATA_8BIT,
|
||||
FIFO_DATA_16BIT,
|
||||
FIFO_DATA_32BIT,
|
||||
FIFO_DATA_8BIT, // FIFO <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB> 8bit
|
||||
FIFO_DATA_16BIT, // FIFO <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB> 16bit
|
||||
FIFO_DATA_32BIT, // FIFO <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB> 32bit
|
||||
}fifo_data_type_enum;
|
||||
|
||||
typedef struct
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint8 execution; // ִ<>в<EFBFBD><D0B2><EFBFBD>
|
||||
fifo_data_type_enum type; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
@@ -93,4 +104,3 @@ fifo_state_enum fifo_read_tail_buffer (fifo_struct *fifo, void *dat, uint32 *l
|
||||
fifo_state_enum fifo_init (fifo_struct *fifo, fifo_data_type_enum type, void *buffer_addr, uint32 size);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user