Compare commits

..

31 Commits

Author SHA1 Message Date
Glz
4e577da707 Merge branch 'master' of https://git.brisky.space/btl143/QDAC-firmware 2024-08-14 20:23:07 +08:00
Glz
dccfedc74c 1 2024-08-14 20:22:55 +08:00
8b94eb2eff fix:修复菜单上下键反了的问题
feat:增加cross处理开关
2024-08-13 21:47:30 +08:00
Glz
2db1937c89 日常更新 2024-08-13 21:41:10 +08:00
Glz
30c9ee1f76 日常更新 2024-08-10 21:02:20 +08:00
5f7b200854 修复曝光显示位数 2024-07-17 10:52:02 +08:00
94222071e9 修复曝光异常bug 2024-07-14 14:34:07 +08:00
f7b52d9d2e feat:增加避障时间可调参数 2024-07-13 19:10:00 +08:00
Glz
b88aaf47e5 日常更新 2024-07-13 19:00:45 +08:00
af031e23d8 feat:增加曝光調參 2024-07-08 19:14:34 +08:00
Glz
dc874bf6f1 避障修改 2024-07-08 17:54:34 +08:00
336d1bc100 fix:修復幾個bug 2024-07-05 21:29:03 +08:00
bmy
be37b5d206 feat: 实验性上行数据接收 2024-07-05 14:50:53 +08:00
bmy
296d02ff4a pref: 修改glz的单词拼写错误 2024-07-05 14:16:20 +08:00
Glz
5d56543f64 日常更新 2024-07-05 14:12:01 +08:00
Glz
7facae7a1a Merge branch 'master' of https://git.brisky.space/btl143/QDAC-firmware 2024-07-03 16:37:57 +08:00
Glz
770247f9b6 日常 2024-07-03 16:37:53 +08:00
61a92c8620 日常 2024-07-03 16:32:45 +08:00
a94db790a6 避障 2024-07-03 16:30:37 +08:00
Glz
1166f71883 再次提交 2024-07-02 17:18:19 +08:00
Glz
047a907eac 避障bug测试 2024-07-02 16:56:43 +08:00
bmy
cb87de5508 同步逐飞库部分接口到v370版本 2024-06-30 16:29:24 +08:00
Glz
0f45c981a6 状态下发延时 2024-06-30 15:55:49 +08:00
Glz
2b5ea8434e 测试bug 2024-06-26 17:27:38 +08:00
Glz
57e132c535 更新 2024-06-18 16:21:19 +08:00
Glz
3605e98cec 修复bug 2024-06-16 21:55:43 +08:00
Glz
7f8e108170 Merge branch 'master' of https://git.brisky.space/btl143/QDAC-firmware 2024-06-16 21:54:30 +08:00
Glz
b155d3ce14 日常更新 2024-06-16 21:52:42 +08:00
a086ce17e4 日常 2024-05-27 21:17:40 +08:00
bmy
3fe85dc7db Merge branches 'master' and 'master' of http://git.brisky.space/btl143/QDAC-firmware 2024-05-25 22:50:57 +08:00
bmy
194d26a9e0 fix: 修复下位机复位异常发送导致上位机卡死的问题
经测试确实是 ORE 置位导致无法退出中断(现象为反复进入中断 ORE 和 FE 置位) fix #1
目前将串口2接收中断暂时打开,看后续是否有需求使用
2024-04-08 17:30:26 +08:00
35 changed files with 1085 additions and 555 deletions

View File

@@ -65,10 +65,9 @@
"libList": [ "libList": [
"libraries/zf_device" "libraries/zf_device"
], ],
"sourceDirList": [],
"defineList": [] "defineList": []
} }
} }
}, },
"version": "3.3" "version": "3.4"
} }

View File

@@ -7,8 +7,8 @@
#include "lwrb.h" #include "lwrb.h"
#include "crc16.h" #include "crc16.h"
uint8_t frame_buffer_recv[(2 * (4 + BY_FRAME_DATA_NUM * sizeof(uint32_t))) + 1]; 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 * sizeof(uint32_t)]; uint8_t frame_buffer_send[4 + BY_FRAME_DATA_NUM_SEND * sizeof(uint32_t)];
uint8_t frame_parse_busy; uint8_t frame_parse_busy;
lwrb_t lwrb_ctx; lwrb_t lwrb_ctx;
@@ -16,13 +16,13 @@ void by_frame_init(void)
{ {
lwrb_init(&lwrb_ctx, frame_buffer_recv, sizeof(frame_buffer_recv)); // lwrb 最大元素数量为 buff 大小减一 lwrb_init(&lwrb_ctx, frame_buffer_recv, sizeof(frame_buffer_recv)); // lwrb 最大元素数量为 buff 大小减一
uart_init(BY_FRAME_UART_INDEX, BY_FRAME_UART_BAUDRATE, BY_FRAME_UART_TX_PIN, BY_FRAME_UART_RX_PIN); uart_init(BY_FRAME_UART_INDEX, BY_FRAME_UART_BAUDRATE, BY_FRAME_UART_TX_PIN, BY_FRAME_UART_RX_PIN);
// uart_rx_interrupt(BY_FRAME_UART_INDEX, ENABLE); 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; 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[0] = BY_FRAME_HEAD_1;
frame_buffer_send[1] = BY_FRAME_HEAD_2; 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); // 缓冲区大小 uint32_t len = lwrb_get_full(&lwrb_ctx); // 缓冲区大小
uint8_t status = 0; // 状态 0-未找到帧头 1-找到帧头 2-校验 uint8_t status = 0; // 状态 0-未找到帧头 1-找到帧头 2-校验
uint16_t frame_start = 0; // 帧起始位置 uint16_t frame_start = 0; // 帧起始位置
uint8_t frame_buf[4 + BY_FRAME_DATA_NUM * sizeof(uint32_t)] = {0}; // 帧 uint8_t frame_buf[4 + BY_FRAME_DATA_NUM_RECV * sizeof(uint32_t)] = {0}; // 帧
uint8_t buf[(4 + BY_FRAME_DATA_NUM * sizeof(uint32_t)) * 2] = {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 * sizeof(uint32_t); const uint8_t data_byte_num = BY_FRAME_DATA_NUM_RECV * sizeof(uint32_t);
if (len < 2 * (4 + data_byte_num)) { if (len < 2 * (4 + data_byte_num)) {
// 当前要求缓冲区满 // 当前要求缓冲区满

View File

@@ -16,14 +16,12 @@
#define BY_FRAME_UART_INDEX (UART_2) #define BY_FRAME_UART_INDEX (UART_2)
#define BY_FRAME_UART_BAUDRATE (115200) #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 uint8_t frame_buffer[50];
extern void by_frame_init(void); extern void by_frame_init(void);
void by_frame_send(uint32_t *data_array); void by_frame_send(uint32_t *data_array);
void by_frame_parse(uint32_t *data_array); void by_frame_parse(uint32_t *data_array);
extern void by_frame_parse_uart_handle(uint8_t data); extern void by_frame_parse_uart_handle(uint8_t data);
#endif #endif

View File

@@ -2,7 +2,15 @@
#include "gl_headfile.h" #include "gl_headfile.h"
enum barrier_type_e barrier_type = BARRIER_NONE; 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() void CheckBarrier()
{ {
if (barrier_type == BARRIER_NONE && Lpt0_found_barrier_in && !Lpt1_found_barrier_in && is_straight1) { if (barrier_type == BARRIER_NONE && Lpt0_found_barrier_in && !Lpt1_found_barrier_in && is_straight1) {
@@ -15,49 +23,222 @@ void CheckBarrier()
void RunBarrier() void RunBarrier()
{ {
if (barrier_type == BARRIER_LEFT_BEGIN) { if (barrier_type == BARRIER_LEFT_BEGIN || barrier_type == BARRIER_LEFT_RUNNING) {
track_type = TRACK_RIGHT; track_type = TRACK_RIGHT;
if (Lpt0_found) { if (barrier_type == BARRIER_LEFT_BEGIN)
Lpt0_found_count++; {
} timer_clear(TIM_2);
if (Lpt0_found_count >= 1) { timer_start(TIM_2);
Lpt0_found_count = 0;
barrier_type = BARRIER_LEFT_RUNNING; barrier_type = BARRIER_LEFT_RUNNING;
track_type = TRACK_RIGHT;
timer_clear(TIM_3);
timer_start(TIM_3);
} }
} else if (barrier_type == BARRIER_LEFT_RUNNING) { if (barrier_type == BARRIER_LEFT_RUNNING)
track_type = TRACK_RIGHT; {
time_barrier = timer_get(TIM_3); if (timer_get(TIM_2) >= barrirer_time)
if (time_barrier >= 250) { {
barrier_type = BARRIER_NONE; barrier_type = BARRIER_NONE;
track_type = TRACK_RIGHT; timer_stop(TIM_2);
timer_start(TIM_3); timer_clear(TIM_2);
timer_clear(TIM_3); }
else{
barrier_type = BARRIER_LEFT_RUNNING;
} }
} }
if (barrier_type == BARRIER_RIGHT_BEGIN) {
track_type = TRACK_LEFT; // if (barrier_begin_flag == 0) {
if (Lpt1_found) { // timer_clear(TIM_3);
Lpt1_found_count++; // 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; barrier_type = BARRIER_RIGHT_RUNNING;
track_type = TRACK_LEFT;
timer_clear(TIM_3);
timer_start(TIM_3);
} }
} else if (barrier_type == BARRIER_RIGHT_RUNNING) { if (barrier_type == BARRIER_RIGHT_RUNNING)
track_type = TRACK_LEFT; {
time_barrier = timer_get(TIM_3); if (timer_get(TIM_2) >= barrirer_time)
if (time_barrier >= 250) { {
timer_start(TIM_3);
timer_clear(TIM_3);
barrier_type = BARRIER_NONE; 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);
// }
// }

View File

@@ -10,11 +10,31 @@ enum barrier_type_e {
BARRIER_LEFT_OUT, BARRIER_LEFT_OUT,
BARRIER_RIGHT_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 CheckBarrier(void);
void Check_s(void);
void RunBarrier(void); void RunBarrier(void);
void Check_shield(void);
#endif /* COMMON_H_ */ #endif /* COMMON_H_ */

View File

@@ -15,6 +15,8 @@ int32_t Right_Border_ToLeft_Circle = 0;
int32_t Left_Border_ToRight_Circle = 0; int32_t Left_Border_ToRight_Circle = 0;
int32_t Right_Border_ToRight_Circle = 0; int32_t Right_Border_ToRight_Circle = 0;
int32_t ceshi = 0;
void CheckCircle() void CheckCircle()
{ {
// 非圆环模式下单边L角点, 单边长直道 // 非圆环模式下单边L角点, 单边长直道
@@ -149,13 +151,13 @@ void RunCircle()
{ {
Right_Border_None_Circle++; Right_Border_None_Circle++;
} }
if (pts_resample_right_count > 0.7 / RESAMPLEDIST && if (pts_resample_right_count > (0.7 / RESAMPLEDIST) && Right_Border_None_Circle > FRAMENONE) {
Right_Border_None_Circle > FRAMENONE) {
circle_type = CIRCLE_NONE; circle_type = CIRCLE_NONE;
Right_Border_None_Circle = 0; Right_Border_None_Circle = 0;
Right_Border_Have_Circle = 0; Right_Border_Have_Circle = 0;
Left_Border_ToLeft_Circle = 0; Left_Border_ToLeft_Circle = 0;
Left_Border_ToRight_Circle = 0; Left_Border_ToRight_Circle = 0;
} }
} }
} }

View File

@@ -17,6 +17,7 @@ enum circle_type_e {
}; };
extern enum circle_type_e circle_type; extern enum circle_type_e circle_type;
extern int32_t ceshi;
void CheckCircle(void); void CheckCircle(void);
void RunCircle(void); void RunCircle(void);

View File

@@ -4,17 +4,19 @@
#define IMAGE_H (MT9V03X_H) #define IMAGE_H (MT9V03X_H)
#define IMAGE_W (MT9V03X_W) #define IMAGE_W (MT9V03X_W)
#define BEGINH_L (61) #define BEGINH_L (61)
#define BEGINH_L_curvature (75)
#define BEGINH_R (61) #define BEGINH_R (61)
#define BEGINH_R_curvature (75)
#define BEGINW_L (-18) #define BEGINW_L (-18)
#define BEGINW_R (-12) #define BEGINW_R (-12)
#define PT_MAXLEN (75) #define PT_MAXLEN (75)
#define GET_PIX_1C(IMG, H, W) (IMG[(H) * MT9V03X_W + (W)]) // 获取像素点的值 #define GET_PIX_1C(IMG, H, W) (IMG[(H) * MT9V03X_W + (W)]) // 获取像素点的值
#define FIX_BINTHRESHOLD (140) // 设置最开始的阈值
#define SELFADAPT_KERNELSIZE (7) // 巡线区域核大小 #define SELFADAPT_KERNELSIZE (7) // 巡线区域核大小
#define FILTER_KERNELSIZE (7) // 滤波核大小 #define FILTER_KERNELSIZE (7) // 滤波核大小
#define SELFADAPT_OFFSET (8) // 适应性块大小 #define SELFADAPT_OFFSET (8) // 适应性块大小
#define PIXPERMETER (70.0f) #define PIXPERMETER (70.0f)
#define PIXPERMETER_ACROSS (72.0f) #define PIXPERMETER_ACROSS (72.0f)
#define PIXPERMETER_ACROSS_BARRIER (10.0f)
#define RESAMPLEDIST (0.02f) #define RESAMPLEDIST (0.02f)
#define ANGLEDIST (0.2f) #define ANGLEDIST (0.2f)
#define ANGLEDIST_barrier (0.06f) #define ANGLEDIST_barrier (0.06f)

View File

@@ -5,23 +5,37 @@ enum cross_type_e cross_type = CROSS_NONE;
bool far_Lpt0_found, far_Lpt1_found; bool far_Lpt0_found, far_Lpt1_found;
int32_t Both_Boder_None_Cross; int32_t Both_Boder_None_Cross;
int far_Lpt0_rpts0s_id, far_Lpt1_rpts1s_id; 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; bool Xfound = Lpt0_found && Lpt1_found;
if ((int)cross_open == 0) {
if (cross_type == CROSS_NONE && Xfound) { if (cross_type == CROSS_NONE && Xfound) {
cross_type = CROSS_BEGIN; 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; bool Xfound = Lpt0_found && Lpt1_found;
// 检测到十字,先按照近线走 // 检测到十字,先按照近线走
if (cross_easy == 0) {
if (cross_type == CROSS_BEGIN) { if (cross_type == CROSS_BEGIN) {
if (Lpt0_found) { if (Lpt0_found) {
mid_left_count = pts_resample_left_count = Lpt0_rpts0s_id; mid_left_count = pts_resample_left_count = Lpt0_rpts0s_id;
track_type = TRACK_LEFT; track_type = TRACK_LEFT;
} } else if (Lpt1_found) {
else if(Lpt1_found) {
mid_right_count = pts_resample_right_count = Lpt1_rpts1s_id; mid_right_count = pts_resample_right_count = Lpt1_rpts1s_id;
track_type = TRACK_RIGHT; track_type = TRACK_RIGHT;
} }
@@ -30,7 +44,6 @@ void RunCross() {
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; cross_type = CROSS_IN;
} }
} }
// 远线控制进十字,begin_y渐变靠近防丢线 // 远线控制进十字,begin_y渐变靠近防丢线
if (cross_type == CROSS_IN) { if (cross_type == CROSS_IN) {
@@ -43,17 +56,63 @@ void RunCross() {
if (Both_Boder_None_Cross > 2 && pts_resample_left_count > 20 && pts_resample_right_count > 20) { if (Both_Boder_None_Cross > 2 && pts_resample_left_count > 20 && pts_resample_right_count > 20) {
cross_type = CROSS_NONE; cross_type = CROSS_NONE;
Both_Boder_None_Cross = 0; 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;
}
void cross_farline(){ // 近角点过少,进入远线控制
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()
{
int cross_width = 4; int cross_width = 4;
int far_y1 = 0, far_y2 = 0; int far_y1 = 0, far_y2 = 0;
int far_x1 = 0, far_x2 = 0; int far_x1 = 0, far_x2 = 0;
@@ -61,17 +120,15 @@ void cross_farline(){
pts_far_left_count = sizeof(pts_far_left) / sizeof(pts_far_left[0]); pts_far_left_count = sizeof(pts_far_left) / sizeof(pts_far_left[0]);
int w1 = IMAGE_W / 2 - BEGINW_R, h1 = BEGINH_L; int w1 = IMAGE_W / 2 - BEGINW_R, h1 = BEGINH_L;
for(;w1>cross_width*2; w1--) for (; w1 > cross_width * 2; w1--) {
{
if (GET_PIX_1C(mt9v03x_image_copy[0], h1, w1 - 1) < FIX_BINTHRESHOLD) { if (GET_PIX_1C(mt9v03x_image_copy[0], h1, w1 - 1) < FIX_BINTHRESHOLD) {
far_x1 = w1 - cross_width; far_x1 = w1 - cross_width;
break; break;
} }
} }
/*如果一行全为白色没写*/ /*如果一行全为白色没写*/
if (far_x1 <= 30) if (far_x1 <= 4) {
{ far_x1 = 4;
far_x1 = 30;
} }
for (; h1 > 0; h1--) { for (; h1 > 0; h1--) {
@@ -84,23 +141,21 @@ void cross_farline(){
} }
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); SearchLineAdaptive_Left(mt9v03x_image_copy[0], SELFADAPT_KERNELSIZE, SELFADAPT_OFFSET, far_y1, far_x1, pts_far_left, &pts_far_left_count);
} } else
else pts_far_left_count = 0; pts_far_left_count = 0;
int w2 = IMAGE_W / 2 + BEGINW_L, h2 = BEGINH_R; int w2 = IMAGE_W / 2 + BEGINW_L, h2 = BEGINH_R;
white_found = false; white_found = false;
pts_far_right_count = sizeof(pts_far_right) / sizeof(pts_far_right[0]); pts_far_right_count = sizeof(pts_far_right) / sizeof(pts_far_right[0]);
for(;w2 < IMAGE_W - cross_width*2; w2++) for (; w2 < IMAGE_W - cross_width * 2; w2++) {
{
if (GET_PIX_1C(mt9v03x_image_copy[0], h2, w2 + 1) < FIX_BINTHRESHOLD) { if (GET_PIX_1C(mt9v03x_image_copy[0], h2, w2 + 1) < FIX_BINTHRESHOLD) {
far_x2 = w2 + cross_width; far_x2 = w2 + cross_width;
break; break;
} }
} }
/*如果一行全为白色没写*/ /*如果一行全为白色没写*/
if (far_x2 >= 120) if (far_x2 >= 136) {
{ far_x2 = 136;
far_x2 = 120;
} }
for (; h2 > 0; h2--) { for (; h2 > 0; h2--) {
@@ -113,8 +168,8 @@ void cross_farline(){
} }
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); SearchLineAdaptive_Right(mt9v03x_image_copy[0], SELFADAPT_KERNELSIZE, SELFADAPT_OFFSET, far_y2, far_x2, pts_far_right, &pts_far_right_count);
} } else
else pts_far_right_count = 0; pts_far_right_count = 0;
// 透视变换 // 透视变换
for (int i = 0; i < pts_far_left_count; i++) { for (int i = 0; i < pts_far_left_count; i++) {
@@ -141,7 +196,6 @@ void cross_farline(){
pts_far_resample_right_count = sizeof(pts_far_resample_right) / sizeof(pts_far_resample_right[0]); 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); 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; int valid_far_points_count = 0;
for (int i = 0; i < pts_far_resample_left_count; i++) { for (int i = 0; i < pts_far_resample_left_count; i++) {
@@ -200,19 +254,15 @@ void cross_farline(){
} }
} }
for (int i = 0; i < pts_far_resample_right_count; i++) { for (int i = 0; i < pts_far_resample_right_count; i++) {
if (far_angle_new_right[i] == 0) continue; if (far_angle_new_right[i] == 0) continue;
int im1 = 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); 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; 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) { if (far_Lpt1_found == false && (66. / 180. * PI32) < conf && conf < 140. / 180. * PI32 && i < 0.7 / RESAMPLEDIST) {
far_Lpt1_rpts1s_id = i; far_Lpt1_rpts1s_id = i;
far_Lpt1_found = true; far_Lpt1_found = true;
} }
} }
} }

View File

@@ -10,6 +10,7 @@ enum cross_type_e {
extern enum cross_type_e cross_type; extern enum cross_type_e cross_type;
extern int32_t Both_Boder_None_Cross; extern int32_t Both_Boder_None_Cross;
extern int far_Lpt0_rpts0s_id, far_Lpt1_rpts1s_id; extern int far_Lpt0_rpts0s_id, far_Lpt1_rpts1s_id;
extern float cross_open;
void CheckCross(void); void CheckCross(void);
void RunCross(void); void RunCross(void);

View File

@@ -6,6 +6,11 @@ int32_t pts_left[PT_MAXLEN][2];
int32_t pts_right[PT_MAXLEN][2]; int32_t pts_right[PT_MAXLEN][2];
int32_t pts_left_count; int32_t pts_left_count;
int32_t pts_right_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_left[PT_MAXLEN][2];
int32_t pts_far_right[PT_MAXLEN][2]; int32_t pts_far_right[PT_MAXLEN][2];
int32_t pts_far_left_count; 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_left[PT_MAXLEN][2];
float mid_right[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_left_count;
int32_t mid_right_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_left[PT_MAXLEN];
float angle_new_right[PT_MAXLEN]; float angle_new_right[PT_MAXLEN];
@@ -112,5 +123,8 @@ float rptsn[PT_MAXLEN][2];
int32_t rptsn_num; int32_t rptsn_num;
float aim_distance; float aim_distance;
float aim_judge_far=0.3f; float aim_judge_far=0.3f;
float FIX_BINTHRESHOLD = 140;
track_type_e track_type = TRACK_RIGHT; track_type_e track_type = TRACK_RIGHT;
int begin_flag = 0;

View File

@@ -16,10 +16,15 @@ extern int32_t pts_left[PT_MAXLEN][2];
extern int32_t pts_right[PT_MAXLEN][2]; extern int32_t pts_right[PT_MAXLEN][2];
extern int32_t pts_left_count; extern int32_t pts_left_count;
extern int32_t pts_right_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_left[PT_MAXLEN][2];
extern int32_t pts_far_right[PT_MAXLEN][2]; extern int32_t pts_far_right[PT_MAXLEN][2];
extern int32_t pts_far_left_count; extern int32_t pts_far_left_count;
extern int32_t pts_far_right_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_l[PT_MAXLEN][2];
extern float pts_inv_r[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_left[PT_MAXLEN][2];
extern float mid_right[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_left_count;
extern int32_t mid_right_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_left[PT_MAXLEN];
extern float angle_new_right[PT_MAXLEN]; extern float angle_new_right[PT_MAXLEN];
@@ -125,5 +136,7 @@ extern float aim_distance;
extern float aim_judge_far; extern float aim_judge_far;
extern track_type_e track_type; extern track_type_e track_type;
extern float FIX_BINTHRESHOLD;
extern int begin_flag;
#endif #endif

View File

@@ -44,7 +44,7 @@ void CheckGarage()
int banmaxian_hangshu = 0;//斑马线行数 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_kuandu=0;
//int banmaxian_hangshu=0; //int banmaxian_hangshu=0;

View File

@@ -5,6 +5,7 @@
enum garage_type_e { enum garage_type_e {
GARAGE_NONE, // 非车库模式 GARAGE_NONE, // 非车库模式
GARAGE_FOUND, GARAGE_FOUND,
OUT_STOP,
}; };
extern enum garage_type_e garage_type; extern enum garage_type_e garage_type;

View File

@@ -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; float conf = fabs(angle_left_barrier[i]) - (fabs(angle_left_barrier[im1]) + fabs(angle_left_barrier[ip1])) / 2;
// L 角点阈值 // 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; 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; Lpt0_found_barrier = true;
} }
else{
Lpt0_found_barrier = false;
}
//Lpt0_found_barrier = true;
}
} }
if (Lpt0_found_barrier) { 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]); 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++) { for (int i = 0; i < pts_resample_right_count; i++) {
if (angle_new_right[i] == 0) continue; if (angle_new_right[i] == 0) continue;
int im1 = clip(i - (int)round(ANGLEDIST / RESAMPLEDIST), 0, pts_resample_right_count - 1); 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); 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; 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; 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; Lpt1_found_barrier = true;
} }
else{
Lpt1_found_barrier = false;
}
//Lpt1_found_barrier = true;
}
} }
if (Lpt1_found_barrier) { 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]); 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]);

View File

@@ -237,3 +237,4 @@ int is_curve(float angle[], int n, float threshold) {
return 0; // 不是弯道 return 0; // 不是弯道
} }

View File

@@ -11,7 +11,7 @@
void img_processing() { void img_processing() {
//
int w1 = IMAGE_W / 2 - BEGINW_R, h1 = BEGINH_L; int w1 = IMAGE_W / 2 - BEGINW_R, h1 = BEGINH_L;
pts_left_count = sizeof(pts_left) / sizeof(pts_left[0]); pts_left_count = sizeof(pts_left) / sizeof(pts_left[0]);
for (; w1 > 0; w1--) { 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); SearchLineAdaptive_Left(mt9v03x_image_copy[0], SELFADAPT_KERNELSIZE, SELFADAPT_OFFSET, h1, w1, pts_left, &pts_left_count);
} }
else pts_left_count = 0; 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; int w2 = IMAGE_W / 2 + BEGINW_L, h2 = BEGINH_R;
pts_right_count = sizeof(pts_right) / sizeof(pts_right[0]); 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); SearchLineAdaptive_Right(mt9v03x_image_copy[0], SELFADAPT_KERNELSIZE, SELFADAPT_OFFSET, h2, w2, pts_right, &pts_right_count);
} }
else pts_right_count = 0; 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++) { for (int i = 0; i < pts_left_count; i++) {
@@ -87,6 +113,7 @@ void img_processing() {
} }
} }
pts_resample_right_count = valid_points_count; 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); 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; 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;
} }

View File

@@ -2,8 +2,12 @@
#include "gl_headfile.h" #include "gl_headfile.h"
enum state_type_e state_type =0; enum state_type_e state_type =0;
enum state_type_e last_state =0;
float cricle_aim=0.2f; float cricle_aim=0.2f;
float cross_aim=0.49f; float cross_aim=0.49f;
float common_aim=0.35f; 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_aim=0.5f;
float barrier_offset=17.0f; float barrier_offset=10.0f;

View File

@@ -6,12 +6,17 @@ enum state_type_e {
TURN_STATE, TURN_STATE,
STRAIGHT_STATE, STRAIGHT_STATE,
CIRCLE_STATE, CIRCLE_STATE,
CIRCLE_RUNNING_STATE,
BARRIER_STATE,
}; };
extern enum state_type_e last_state;
extern enum state_type_e state_type; extern enum state_type_e state_type;
extern float cricle_aim; extern float cricle_aim;
extern float cross_aim; extern float cross_aim;
extern float common_aim; extern float common_aim;
extern float straight_aim;
extern float turn_aim;
extern float mid_aim;
extern float barrier_aim; extern float barrier_aim;
extern float barrier_offset; extern float barrier_offset;

View File

@@ -1,14 +1,23 @@
#include "zf_common_headfile.h" #include "zf_common_headfile.h"
#include "gl_headfile.h" #include "gl_headfile.h"
#include "jj_blueteeth.h" #include "jj_blueteeth.h"
#include <float.h>
float (*mid_track)[2]; float (*mid_track)[2];
int32_t mid_track_count; int32_t mid_track_count;
float pure_angle; float pure_angle;
float pure_angle_half;
float curvature;
float dx_near; float dx_near;
float curvature;
float last_curvature;
float (*rpts)[2]; float (*rpts)[2];
int rpts_num; int rpts_num;
float last_pure_angle = 0.0f; 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) float leastSquaresSlope(float points[][2], int n)
{ {
@@ -40,7 +49,41 @@ float leastSquaresSlope(float points[][2], int n)
return temp; 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; float b_x = a_x - (b_y - a_y) * slope;
return b_x; return b_x;
} }
@@ -62,18 +105,18 @@ void tracking()
void aim_distance_select(void) void aim_distance_select(void)
{ {
if (cross_type != CROSS_NONE) { if (cross_type != CROSS_NONE) {
aim_distance = cricle_aim;
} else if (circle_type != CIRCLE_NONE) {
aim_distance = cross_aim; aim_distance = cross_aim;
} else if (circle_type != CIRCLE_NONE) {
aim_distance = cricle_aim;
} else if (barrier_type != BARRIER_NONE) { } else if (barrier_type != BARRIER_NONE) {
aim_distance = barrier_aim; aim_distance = barrier_aim;
} else {
aim_distance = common_aim;
} }
} }
void ElementJudge() void ElementJudge()
{ {
if (shield_type == SHIELD_NONE) {
CheckGarage(); CheckGarage();
if (garage_type == GARAGE_NONE) { if (garage_type == GARAGE_NONE) {
CheckCross(); CheckCross();
@@ -81,6 +124,10 @@ void ElementJudge()
CheckBarrier(); CheckBarrier();
if (barrier_type == BARRIER_NONE) { if (barrier_type == BARRIER_NONE) {
CheckCircle(); CheckCircle();
if (circle_type == CIRCLE_NONE) {
Check_s();
}
}
} }
} }
} }
@@ -88,6 +135,7 @@ void ElementJudge()
if (garage_type != GARAGE_NONE) { if (garage_type != GARAGE_NONE) {
cross_type = CROSS_NONE; cross_type = CROSS_NONE;
circle_type = CIRCLE_NONE; circle_type = CIRCLE_NONE;
barrier_type = BARRIER_NONE;
} }
if (cross_type != CROSS_NONE) { if (cross_type != CROSS_NONE) {
circle_type = CIRCLE_NONE; circle_type = CIRCLE_NONE;
@@ -106,17 +154,22 @@ void ElementRun()
else if (cross_type != CROSS_NONE) { else if (cross_type != CROSS_NONE) {
RunCross(); RunCross();
}
else if (circle_type != CIRCLE_NONE) {
RunCircle();
} else if (barrier_type != BARRIER_NONE) { } else if (barrier_type != BARRIER_NONE) {
RunBarrier(); RunBarrier();
} else if (circle_type != CIRCLE_NONE) {
RunCircle();
} else if (s_type != S_NONE) {
// RunS();
} }
} }
void MidLineTrack() 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 (cross_type == CROSS_IN) {
if (track_type == TRACK_LEFT) { if (track_type == TRACK_LEFT) {
mid_track = mid_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); 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; 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 { } else {
if (track_type == TRACK_LEFT) { if (track_type == TRACK_LEFT) {
mid_track = mid_left; mid_track = mid_left;
@@ -135,66 +196,29 @@ void MidLineTrack()
mid_track = mid_right; mid_track = mid_right;
mid_track_count = mid_right_count; 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 cx = InverseMapW[(int)(IMAGE_H * 0.8f)][70];
float cy = InverseMapH[(int)(IMAGE_H * 0.8f)][70]; float cy = InverseMapH[(int)(IMAGE_H * 0.8f)][70];
int neary = (int)mid_track[0][0];
// float slope = leastSquaresSlope(mid_track, mid_track_count); int nearx = (int)mid_track[0][1];
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;
}
}
}
}
// 找最近点 (起始点中线归一化) // 找最近点 (起始点中线归一化)
float min_dist = 1e10; float min_dist = 1e10;
@@ -217,12 +241,29 @@ void MidLineTrack()
rptsn_num = sizeof(rptsn) / sizeof(rptsn[0]); rptsn_num = sizeof(rptsn) / sizeof(rptsn[0]);
GetLinesResample(mid_track + begin_id, mid_track_count - begin_id, rptsn, &rptsn_num, RESAMPLEDIST * PIXPERMETER); 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 = 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_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 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]; 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 c2 = dx2 / dn2;
float s2 = dy2 / dn2; float s2 = dy2 / dn2;
float angle_1 = atan2f(c1 * s2 - c2 * s1, c2 * c1 + s2 * s1); float angle_1 = atan2f(c1 * s2 - c2 * s1, c2 * c1 + s2 * s1);
if (angle_1 >= 0.2f || angle_1 <= -0.2f) { if (angle_1 >= 0.2f || angle_1 <= -0.2f) {
state_type = TURN_STATE; state_type = TURN_STATE;
} else { } else {
@@ -246,54 +288,130 @@ void MidLineTrack()
float dy = cy - rptsn[aim_idx][0]; // + 0.2f * PIXPERMETER; float dy = cy - rptsn[aim_idx][0]; // + 0.2f * PIXPERMETER;
float dn = (dx * dx + dy * dy); float dn = (dx * dx + dy * dy);
float temp_near = 0; 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;
}
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; // pure_angle = -atanf(PIXPERMETER * 2.0f * 0.2f * 0.5f * dx / dn) / PI32 * 180.0f;
if (dy > 0) { if (dy > 0) {
pure_angle = -atanf(dx / dy) / PI32 * 180.0f; pure_angle = -atanf(dx / dy) / PI32 * 180.0f;
last_pure_angle = pure_angle; last_pure_angle = pure_angle;
// last_pure_angle_half = pure_angle_half;
} else { } else {
pure_angle = last_pure_angle; 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; // dx_near = rptsn[aim_idx_near][1] - cx;
// // float dy_near = cy - rptsn[aim_idx_near][0] + 0.2 * PIXPERMETER; // // 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 dn_near = Q_sqrt(dx_near * dx_near + dy_near * dy_near);
// // float error_near = -atan2f(dx_near, dy_near) * 180 / PI32; // // 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; 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) { if (cross_type == CROSS_BEGIN || cross_type == CROSS_IN) {
state_type = STRAIGHT_STATE; 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;
}
}
}
} }

View File

@@ -4,8 +4,13 @@
extern float (*mid_track)[2]; extern float (*mid_track)[2];
extern int32_t mid_track_count; extern int32_t mid_track_count;
extern float pure_angle; extern float pure_angle;
extern float pure_angle_half;
extern float dx_near; 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 aim_distance_select(void);
void tracking(void); void tracking(void);
void ElementJudge(void); void ElementJudge(void);

View File

@@ -34,6 +34,7 @@
********************************************************************************************************************/ ********************************************************************************************************************/
#include "zf_common_headfile.h" #include "zf_common_headfile.h"
#include "gl_headfile.h"
#include "by_button.h" #include "by_button.h"
#include "by_buzzer.h" #include "by_buzzer.h"
#include "by_frame.h" #include "by_frame.h"
@@ -92,8 +93,14 @@ void USART1_IRQHandler(void)
void USART2_IRQHandler(void) void USART2_IRQHandler(void)
{ {
if (USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) { if (USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) {
by_frame_parse_uart_handle((uint8_t)USART_ReceiveData(USART2));
USART_ClearITPendingBit(USART2, USART_IT_RXNE); 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);
}
} }
void USART3_IRQHandler(void) void USART3_IRQHandler(void)
{ {
@@ -279,8 +286,8 @@ void EXTI15_10_IRQHandler(void)
void TIM1_UP_IRQHandler(void) void TIM1_UP_IRQHandler(void)
{ {
if (TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET) { if (TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET) {
by_frame_send(&tiny_frame_param[0].u32);
TIM_ClearITPendingBit(TIM1, TIM_IT_Update); TIM_ClearITPendingBit(TIM1, TIM_IT_Update);
by_frame_send(&tiny_frame_param[0].u32);
by_led_warn_blink(); by_led_warn_blink();
} }
} }

View File

@@ -3,12 +3,14 @@
#include "./page/page.h" #include "./page/page.h"
#include "gl_tracking.h" #include "gl_tracking.h"
#include "gl_state.h" #include "gl_state.h"
#include "gl_data.h"
#include "zf_common_headfile.h" #include "zf_common_headfile.h"
PARAM_INFO Param_Data[DATA_NUM]; PARAM_INFO Param_Data[DATA_NUM];
soft_iic_info_struct eeprom_param; soft_iic_info_struct eeprom_param;
TYPE_UNION iic_buffer[DATA_IN_FLASH_NUM]; TYPE_UNION iic_buffer[DATA_IN_FLASH_NUM];
TYPE_UNION tiny_frame_param[20]; TYPE_UNION tiny_frame_param[20];
uint32_t *addre[2]; uint32_t *addre[2];
float auto_exp;
/** /**
* @brief 参数初始化注册 * @brief 参数初始化注册
* *
@@ -20,10 +22,16 @@ void jj_param_eeprom_init(void)
PARAM_REG(aim_cricle, &cricle_aim, EFLOAT, 1, "cric:"); // 注冊 PARAM_REG(aim_cricle, &cricle_aim, EFLOAT, 1, "cric:"); // 注冊
PARAM_REG(aim_common, &common_aim, EFLOAT, 1, "comm:"); // 注冊 PARAM_REG(aim_common, &common_aim, EFLOAT, 1, "comm:"); // 注冊
PARAM_REG(aim_barrier, &barrier_aim, EFLOAT, 1, "barr:"); 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(offset_barrier, &barrier_offset, EFLOAT, 1, "offs:");
PARAM_REG(delta_x, &pure_angle, EFLOAT, 2, "far:"); 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(); // 注冊 jj_param_read(); // 注冊
} }
/** /**

View File

@@ -23,12 +23,15 @@ typedef enum {
aim_cricle, aim_cricle,
aim_barrier, aim_barrier,
offset_barrier, offset_barrier,
aim_straight,
aim_turn,
aim_mid,
Page2_head, Page2_head,
// 第二页参数 // 第二页参数
imgax_Kp = Page2_head, baoguang = Page2_head,
imgax_Ki, auto_exp_param,
imgax_Kd, barr_time,
cross_sw,
Page3_head, Page3_head,
DATA_IN_FLASH_NUM, DATA_IN_FLASH_NUM,
@@ -64,4 +67,5 @@ void jj_param_eeprom_init(void);
void jj_param_write(void); void jj_param_write(void);
void jj_param_read(void); void jj_param_read(void);
extern float data7; extern float data7;
extern float auto_exp;
#endif #endif

View File

@@ -29,14 +29,15 @@
#include "by_led.h" #include "by_led.h"
#include "jj_param.h" #include "jj_param.h"
#include "jj_blueteeth.h" #include "jj_blueteeth.h"
#include "zf_device_config.h"
int main(void) int main(void)
{ {
TYPE_UNION recv_data[BY_FRAME_DATA_NUM_RECV];
clock_init(SYSTEM_CLOCK_144M); clock_init(SYSTEM_CLOCK_144M);
system_delay_init(); system_delay_init();
debug_init(); debug_init();
mt9v03x_init();
ips200_init(IPS200_TYPE_SPI); ips200_init(IPS200_TYPE_SPI);
by_led_init(); by_led_init();
@@ -46,18 +47,30 @@ int main(void)
jj_bt_init(); jj_bt_init();
jj_param_eeprom_init(); jj_param_eeprom_init();
mt9v03x_init();
mt9v03x_sccb_set_exposure_time((uint16_t)auto_exp);
Page_Init(); Page_Init();
pit_ms_init(TIM1_PIT, 10); pit_ms_init(TIM1_PIT, 10);
timer_init(TIM_3, TIMER_MS); timer_init(TIM_3, TIMER_MS);
timer_init(TIM_2, TIMER_MS);
by_frame_init(); by_frame_init();
printf("start running\r\n"); printf("start running\r\n");
while (1) { 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(); Page_Run();
by_buzzer_run(); by_buzzer_run();
tiny_frame_param[0].f32 = pure_angle; 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[0] = (uint8_t)state_type; // 0: 无状态 1: 弯道 2: 直行
tiny_frame_param[2].u8[1] = (uint8_t)garage_type; // 0: 无车库 1: 有车库 tiny_frame_param[2].u8[1] = (uint8_t)garage_type; // 0: 无车库 1: 有车库
if (mt9v03x_finish_flag) { if (mt9v03x_finish_flag) {
@@ -68,12 +81,14 @@ int main(void)
state_type = COMMON_STATE; state_type = COMMON_STATE;
img_processing(); img_processing();
get_corners(); get_corners();
aim_distance_select();
tracking(); tracking();
ElementJudge(); ElementJudge();
ElementRun(); ElementRun();
aim_distance_select();
MidLineTrack(); MidLineTrack();
bt_printf("type= %d", circle_type); // if (barrier_type) {
// bt_printf("type= %d", barrier_type);
// }
} }
} }
} }

View File

@@ -130,7 +130,7 @@ void Page_Init(void)
PAGE_REG(page_menu, "main"); PAGE_REG(page_menu, "main");
PAGE_REG(page_rtcam, "rtcam"); PAGE_REG(page_rtcam, "rtcam");
PAGE_REG(page_param1, "aim_param"); PAGE_REG(page_param1, "aim_param");
PAGE_REG(page_param2, "param2"); PAGE_REG(page_param2, "exp");
PAGE_REG(page_dparam, "dparam"); PAGE_REG(page_dparam, "dparam");
PAGE_REG(page_reset, "reset"); PAGE_REG(page_reset, "reset");
// PAGE_REG(page_argv); // PAGE_REG(page_argv);

View File

@@ -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 + 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 + 38, track_type, 1);
ips200_show_int(90, 18 + 56, garage_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 + 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 页面事件 * @brief 页面事件

View File

@@ -63,6 +63,7 @@ static void Loop()
ips200_show_uint(160, 224, Lpt1_found_barrier_in, 3); ips200_show_uint(160, 224, Lpt1_found_barrier_in, 3);
ips200_show_uint(200, 165, barrier_type, 3); ips200_show_uint(200, 165, barrier_type, 3);
ips200_show_uint(200, 185, state_type, 5); ips200_show_uint(200, 185, state_type, 5);
//ips200_show_uint(200, 205, ceshi, 5);
} }
/** /**

View File

@@ -33,7 +33,7 @@ static void Setup()
} else if (Get_new_page() == page_param2) { } else if (Get_new_page() == page_param2) {
pafrist = Page2_head; pafrist = Page2_head;
paend = Page3_head; paend = Page3_head;
ips200_show_string(0, 0, "Param2"); ips200_show_string(0, 0, "exp");
} }
palong = paend - pafrist; palong = paend - pafrist;
@@ -102,7 +102,7 @@ static void Event(page_event event)
} }
Print_Curser(Curser, Curser_Last, RGB565_PURPLE); Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
} else if (1 == event_flag) { } else if (1 == event_flag) {
if (page_event_forward == event) { if (page_event_backward == event) {
switch (Param_Data[Curser + pafrist - 1].type) { switch (Param_Data[Curser + pafrist - 1].type) {
case EFLOAT: case EFLOAT:
*((float *)(Param_Data[Curser + pafrist - 1].p_data)) += powf(10, index_power); *((float *)(Param_Data[Curser + pafrist - 1].p_data)) += powf(10, index_power);
@@ -116,7 +116,7 @@ static void Event(page_event event)
default: default:
break; break;
} }
} else if (page_event_backward == event) { } else if ( page_event_forward== event) {
switch (Param_Data[Curser + pafrist - 1].type) { switch (Param_Data[Curser + pafrist - 1].type) {
case EFLOAT: case EFLOAT:
*((float *)(Param_Data[Curser + pafrist - 1].p_data)) -= powf(10.0f, (float)index_power); *((float *)(Param_Data[Curser + pafrist - 1].p_data)) -= powf(10.0f, (float)index_power);

View File

@@ -33,7 +33,7 @@ static void Setup()
} else if (Get_new_page() == page_param2) { } else if (Get_new_page() == page_param2) {
pafrist = Page2_head; pafrist = Page2_head;
paend = Page3_head; paend = Page3_head;
ips200_show_string(0, 0, "Param2"); ips200_show_string(0, 0, "exp");
} }
palong = paend - pafrist; palong = paend - pafrist;
@@ -45,11 +45,19 @@ static void Setup()
Print_Curser(Curser, Curser_Last, RGB565_PURPLE); Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
for (int16 i = 0; i < palong; i++) { for (int16 i = 0; i < palong; i++) {
ips200_show_string(20, i * 18 + 20, Param_Data[i + pafrist].text); ips200_show_string(20, i * 18 + 20, Param_Data[i + pafrist].text);
if (Param_Data[i].type == EINT32) if (Param_Data[i+ pafrist].type == EINT32)
ips200_show_int(60, i * 18 + 20, *((int32 *)(Param_Data[i + pafrist].p_data)), 5); {
else if (Param_Data[i].type == EFLOAT) 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); 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); ips200_show_int(50, palong * 18 + 20, index_power, 5);
} }
@@ -92,6 +100,7 @@ static void Event(page_event event)
return; return;
} else if (page_event_press_long == event) { } else if (page_event_press_long == event) {
jj_param_write(); jj_param_write();
mt9v03x_set_exposure_time(auto_exp);
Page_Shift(page_menu); Page_Shift(page_menu);
return; return;
} }
@@ -102,21 +111,21 @@ static void Event(page_event event)
} }
Print_Curser(Curser, Curser_Last, RGB565_PURPLE); Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
} else if (1 == event_flag) { } else if (1 == event_flag) {
if (page_event_forward == event) { if (page_event_backward == event) {
switch (Param_Data[Curser + pafrist - 1].type) { switch (Param_Data[Curser + pafrist - 1].type) {
case EFLOAT: 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; break;
case EINT32: case EINT32:
*((int32 *)(Param_Data[Curser + pafrist - 1].p_data)) += 1; *((int32 *)(Param_Data[Curser + pafrist - 1].p_data)) += 1;
break; break;
case EUINT32: 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; break;
default: default:
break; break;
} }
} else if (page_event_backward == event) { } else if ( page_event_forward == event) {
switch (Param_Data[Curser + pafrist - 1].type) { switch (Param_Data[Curser + pafrist - 1].type) {
case EFLOAT: case EFLOAT:
*((float *)(Param_Data[Curser + pafrist - 1].p_data)) -= powf(10.0f, (float)index_power); *((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; *((int32 *)(Param_Data[Curser + pafrist - 1].p_data)) -= 1;
break; break;
case EUINT32: 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; break;
default: default:
break; break;
} }
} else if (page_event_press_short == event) { } else if (page_event_press_short == event) {
index_power++; index_power++;
if (index_power > 2) { if (index_power > 5) {
index_power = -2; index_power = -2;
} }
ips200_show_int(50, palong * 18 + 20, index_power, 5); 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) if (EINT32 == Param_Data[Curser + pafrist - 1].type)
ips200_show_int(60, Curser * 18 + 2, *((int32 *)(Param_Data[Curser + pafrist - 1].p_data)), 5); 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) 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) 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);
} }
} }

View File

@@ -171,10 +171,10 @@ void Show_Marked_Image(void)
uint16_t mix_y = START_Y + (uint16_t)(rptsn[i][0] * vertical_zoom_rate); 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); 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); ips200_draw_rect(r_x - 2, r_y, r_x, r_y + 1, RGB565_BLUE);
} }

View File

@@ -34,6 +34,7 @@
********************************************************************************************************************/ ********************************************************************************************************************/
#include "zf_common_debug.h" #include "zf_common_debug.h"
#include "zf_common_fifo.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) fifo_state_enum fifo_clear (fifo_struct *fifo)
{ {
zf_assert(fifo != NULL); zf_assert(NULL != fifo);
fifo_state_enum return_state = FIFO_SUCCESS; fifo_state_enum return_state = FIFO_SUCCESS; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
do do
{ {
if(FIFO_CLEAR & fifo->execution) // if(FIFO_IDLE != fifo->execution) // <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD>ǰ FIFO <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
{ // {
return_state = FIFO_CLEAR_UNDO; // return_state = FIFO_RESET_UNDO; // <20><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
break; // break;
} // }
fifo->execution |= FIFO_CLEAR; fifo->execution |= FIFO_RESET; // <20><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>λ
fifo->head = 0; fifo->head = 0; // <20><><EFBFBD><EFBFBD> FIFO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>λ
fifo->end = 0; fifo->end = 0; // <20><><EFBFBD><EFBFBD> FIFO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>λ
fifo->size = fifo->max; fifo->size = fifo->max; // <20><><EFBFBD><EFBFBD> FIFO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>λ
switch(fifo->type) switch(fifo->type)
{ {
case FIFO_DATA_8BIT: case FIFO_DATA_8BIT: memset(fifo->buffer, 0, fifo->max); break;
memset(fifo->buffer, 0, fifo->max); case FIFO_DATA_16BIT: memset(fifo->buffer, 0, fifo->max * 2); break;
break; case FIFO_DATA_32BIT: memset(fifo->buffer, 0, fifo->max * 4); 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_IDLE; // <20><><EFBFBD><EFBFBD>״̬<D7B4><CCAC>λ
fifo->execution &= ~FIFO_CLEAR;
}while(0); }while(0);
return return_state; return return_state;
} }
@@ -122,7 +116,7 @@ fifo_state_enum fifo_clear (fifo_struct *fifo)
uint32 fifo_used (fifo_struct *fifo) uint32 fifo_used (fifo_struct *fifo)
{ {
zf_assert(fifo != NULL); 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) fifo_state_enum fifo_write_element (fifo_struct *fifo, uint32 dat)
{ {
zf_assert(fifo != NULL); zf_assert(NULL != fifo);
fifo_state_enum return_state = FIFO_SUCCESS; fifo_state_enum return_state = FIFO_SUCCESS; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
do 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; 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> if(1 <= fifo->size) // ʣ<><CAA3><EFBFBD>ռ<EFBFBD><D5BC>㹻װ<E3B9BB>±<EFBFBD><C2B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{ {
switch(fifo->type) switch(fifo->type)
{ {
case FIFO_DATA_8BIT: case FIFO_DATA_8BIT: ((uint8 *)fifo->buffer)[fifo->head] = dat; break;
((uint8 *)fifo->buffer)[fifo->head] = dat; case FIFO_DATA_16BIT: ((uint16 *)fifo->buffer)[fifo->head] = dat; break;
break; case FIFO_DATA_32BIT: ((uint32 *)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_head_offset(fifo, 1); // ͷָ<CDB7><D6B8>ƫ<EFBFBD><C6AB>
fifo->size -= 1; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><EFBFBD>ȼ<EFBFBD>С fifo->size -= 1; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><EFBFBD>ȼ<EFBFBD>С
} }
else 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); }while(0);
return return_state; 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) fifo_state_enum fifo_write_buffer (fifo_struct *fifo, void *dat, uint32 length)
{ {
zf_assert(fifo != NULL); zf_assert(NULL != fifo);
fifo_state_enum return_state = FIFO_SUCCESS; fifo_state_enum return_state = FIFO_SUCCESS; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
uint32 temp_length = 0; uint32 temp_length = 0;
do do
{ {
if(NULL == dat) if(NULL == dat)
{ {
return_state = FIFO_BUFFER_NULL; return_state = FIFO_BUFFER_NULL; // <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
break; 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; 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> 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) switch(fifo->type)
{ {
case FIFO_DATA_8BIT: case FIFO_DATA_8BIT:
{
memcpy( memcpy(
&(((uint8 *)fifo->buffer)[fifo->head]), &(((uint8 *)fifo->buffer)[fifo->head]),
dat, temp_length); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 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]), &(((uint8 *)dat)[temp_length]),
length - temp_length); // <20><><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 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> fifo_head_offset(fifo, length - temp_length); // ͷָ<CDB7><D6B8>ƫ<EFBFBD><C6AB>
break; }break;
case FIFO_DATA_16BIT: case FIFO_DATA_16BIT:
{
memcpy( memcpy(
&(((uint16 *)fifo->buffer)[fifo->head]), &(((uint16 *)fifo->buffer)[fifo->head]),
dat, temp_length * 2); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 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]), &(((uint16 *)dat)[temp_length]),
(length - temp_length) * 2); // <20><><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (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> fifo_head_offset(fifo, length - temp_length); // ͷָ<CDB7><D6B8>ƫ<EFBFBD><C6AB>
break; }break;
case FIFO_DATA_32BIT: case FIFO_DATA_32BIT:
{
memcpy( memcpy(
&(((uint32 *)fifo->buffer)[fifo->head]), &(((uint32 *)fifo->buffer)[fifo->head]),
dat, temp_length * 4); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 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]), &(((uint32 *)dat)[temp_length]),
(length - temp_length) * 4); // <20><><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (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> fifo_head_offset(fifo, length - temp_length); // ͷָ<CDB7><D6B8>ƫ<EFBFBD><C6AB>
break; }break;
} }
} }
else else
@@ -251,35 +242,36 @@ fifo_state_enum fifo_write_buffer (fifo_struct *fifo, void *dat, uint32 length)
switch(fifo->type) switch(fifo->type)
{ {
case FIFO_DATA_8BIT: case FIFO_DATA_8BIT:
{
memcpy( memcpy(
&(((uint8 *)fifo->buffer)[fifo->head]), &(((uint8 *)fifo->buffer)[fifo->head]),
dat, length); // һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4> dat, length); // һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>
fifo_head_offset(fifo, length); // ͷָ<CDB7><D6B8>ƫ<EFBFBD><C6AB> fifo_head_offset(fifo, length); // ͷָ<CDB7><D6B8>ƫ<EFBFBD><C6AB>
break; }break;
case FIFO_DATA_16BIT: case FIFO_DATA_16BIT:
{
memcpy( memcpy(
&(((uint16 *)fifo->buffer)[fifo->head]), &(((uint16 *)fifo->buffer)[fifo->head]),
dat, length * 2); // һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4> dat, length * 2); // һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>
fifo_head_offset(fifo, length); // ͷָ<CDB7><D6B8>ƫ<EFBFBD><C6AB> fifo_head_offset(fifo, length); // ͷָ<CDB7><D6B8>ƫ<EFBFBD><C6AB>
break; }break;
case FIFO_DATA_32BIT: case FIFO_DATA_32BIT:
{
memcpy( memcpy(
&(((uint32 *)fifo->buffer)[fifo->head]), &(((uint32 *)fifo->buffer)[fifo->head]),
dat, length * 4); // һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4> dat, length * 4); // һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>
fifo_head_offset(fifo, length); // ͷָ<CDB7><D6B8>ƫ<EFBFBD><C6AB> 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>С fifo->size -= length; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><EFBFBD>ȼ<EFBFBD>С
} }
else 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); }while(0);
return return_state; 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) fifo_state_enum fifo_read_element (fifo_struct *fifo, void *dat, fifo_operation_enum flag)
{ {
zf_assert(fifo != NULL); zf_assert(NULL != fifo);
fifo_state_enum return_state = FIFO_SUCCESS; fifo_state_enum return_state = FIFO_SUCCESS; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
do do
{ {
if(NULL == dat) 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; break;
} }
fifo->execution |= FIFO_READ;
if(1 > fifo_used(fifo)) 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) switch(fifo->type)
{ {
case FIFO_DATA_8BIT: case FIFO_DATA_8BIT: *((uint8 *)dat) = ((uint8 *)fifo->buffer)[fifo->end]; break;
*((uint8 *)dat) = ((uint8 *)fifo->buffer)[fifo->end]; case FIFO_DATA_16BIT: *((uint16 *)dat) = ((uint16 *)fifo->buffer)[fifo->end]; break;
break; case FIFO_DATA_32BIT: *((uint32 *)dat) = ((uint32 *)fifo->buffer)[fifo->end]; break;
case FIFO_DATA_16BIT: }
*((uint16 *)dat) = ((uint16 *)fifo->buffer)[fifo->end]; fifo->execution &= ~FIFO_READ; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
break;
case FIFO_DATA_32BIT:
*((uint32 *)dat) = ((uint32 *)fifo->buffer)[fifo->end];
break;
} }
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; 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_end_offset(fifo, 1); // <20>ƶ<EFBFBD> FIFO ͷָ<CDB7><D6B8>
fifo->size += 1; fifo->size += 1; // <20>ͷŶ<CDB7>Ӧ<EFBFBD><D3A6><EFBFBD>ȿռ<C8BF>
fifo->execution &= ~FIFO_CLEAR; fifo->execution &= ~FIFO_CLEAR; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
} }
}while(0); }while(0);
fifo->execution &= FIFO_READ;
return return_state; 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) fifo_state_enum fifo_read_buffer (fifo_struct *fifo, void *dat, uint32 *length, fifo_operation_enum flag)
{ {
zf_assert(fifo != NULL); zf_assert(NULL != fifo);
zf_assert(length != NULL); zf_assert(NULL != length);
fifo_state_enum return_state = FIFO_SUCCESS; fifo_state_enum return_state = FIFO_SUCCESS; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
uint32 temp_length; uint32 temp_length = 0;
uint32 fifo_data_length; uint32 fifo_data_length = 0;
do do
{ {
if(NULL == dat) if(NULL == dat)
{ {
return_state = FIFO_BUFFER_NULL; 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; break;
} }
fifo->execution |= FIFO_READ;
fifo_data_length = fifo_used(fifo); 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>
if(*length > fifo_data_length)
{ {
*length = fifo_data_length; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ij<EFBFBD><C4B3><EFBFBD> *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> 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> 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> if(*length <= temp_length) // <20>һ<E3B9BB><D2BB><EFBFBD>Զ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
{ {
switch(fifo->type) switch(fifo->type)
{ {
case FIFO_DATA_8BIT: case FIFO_DATA_8BIT: memcpy(dat, &(((uint8 *)fifo->buffer)[fifo->end]), *length); break;
memcpy(dat, &(((uint8 *)fifo->buffer)[fifo->end]), *length); case FIFO_DATA_16BIT: memcpy(dat, &(((uint16 *)fifo->buffer)[fifo->end]), *length * 2); break;
break; case FIFO_DATA_32BIT: memcpy(dat, &(((uint32 *)fifo->buffer)[fifo->end]), *length * 4); 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 else
@@ -400,34 +399,38 @@ fifo_state_enum fifo_read_buffer (fifo_struct *fifo, void *dat, uint32 *length,
switch(fifo->type) switch(fifo->type)
{ {
case FIFO_DATA_8BIT: case FIFO_DATA_8BIT:
{
memcpy(dat, &(((uint8 *)fifo->buffer)[fifo->end]), temp_length); memcpy(dat, &(((uint8 *)fifo->buffer)[fifo->end]), temp_length);
memcpy(&(((uint8 *)dat)[temp_length]), fifo->buffer, *length - temp_length); memcpy(&(((uint8 *)dat)[temp_length]), fifo->buffer, *length - temp_length);
break; }break;
case FIFO_DATA_16BIT: case FIFO_DATA_16BIT:
{
memcpy(dat, &(((uint16 *)fifo->buffer)[fifo->end]), temp_length * 2); memcpy(dat, &(((uint16 *)fifo->buffer)[fifo->end]), temp_length * 2);
memcpy(&(((uint16 *)dat)[temp_length]), fifo->buffer, (*length - temp_length) * 2); memcpy(&(((uint16 *)dat)[temp_length]), fifo->buffer, (*length - temp_length) * 2);
break; }break;
case FIFO_DATA_32BIT: case FIFO_DATA_32BIT:
{
memcpy(dat, &(((uint32 *)fifo->buffer)[fifo->end]), temp_length * 4); memcpy(dat, &(((uint32 *)fifo->buffer)[fifo->end]), temp_length * 4);
memcpy(&(((uint32 *)dat)[temp_length]), fifo->buffer, (*length - 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; 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_end_offset(fifo, *length); // <20>ƶ<EFBFBD> FIFO ͷָ<CDB7><D6B8>
fifo->size += *length; fifo->size += *length; // <20>ͷŶ<CDB7>Ӧ<EFBFBD><D3A6><EFBFBD>ȿռ<C8BF>
fifo->execution &= ~FIFO_CLEAR; fifo->execution &= ~FIFO_CLEAR; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
} }
}while(0); }while(0);
fifo->execution &= FIFO_READ;
return return_state; 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) fifo_state_enum fifo_read_tail_buffer (fifo_struct *fifo, void *dat, uint32 *length, fifo_operation_enum flag)
{ {
zf_assert(fifo != NULL); zf_assert(NULL != fifo);
zf_assert(length != NULL); zf_assert(NULL != length);
fifo_state_enum return_state = FIFO_SUCCESS; fifo_state_enum return_state = FIFO_SUCCESS; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
uint32 temp_length; uint32 temp_length = 0;
uint32 fifo_data_length; uint32 fifo_data_length = 0;
do do
{ {
if(NULL == dat) if(NULL == dat)
{ {
return_state = FIFO_BUFFER_NULL; 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; break;
} }
fifo->execution |= FIFO_READ;
fifo_data_length = fifo_used(fifo); fifo_data_length = fifo_used(fifo); // <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD>
if(*length > fifo_data_length) 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> *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> 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)) if((fifo->head > fifo->end) || (fifo->head >= *length))
{ {
switch(fifo->type) switch(fifo->type)
{ {
case FIFO_DATA_8BIT: case FIFO_DATA_8BIT: memcpy(dat, &(((uint8 *)fifo->buffer)[fifo->head - *length]), *length); break;
memcpy(dat, &(((uint8 *)fifo->buffer)[fifo->head - *length]), *length); case FIFO_DATA_16BIT: memcpy(dat, &(((uint16 *)fifo->buffer)[fifo->head - *length]), *length * 2);break;
break; case FIFO_DATA_32BIT: memcpy(dat, &(((uint32 *)fifo->buffer)[fifo->head - *length]), *length * 4);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 else
@@ -489,34 +498,35 @@ fifo_state_enum fifo_read_tail_buffer (fifo_struct *fifo, void *dat, uint32 *len
switch(fifo->type) switch(fifo->type)
{ {
case FIFO_DATA_8BIT: case FIFO_DATA_8BIT:
{
memcpy(dat, &(((uint8 *)fifo->buffer)[fifo->max - temp_length]), temp_length); 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)); memcpy(&(((uint8 *)dat)[temp_length]), &(((uint8 *)fifo->buffer)[fifo->head - *length]), (*length - temp_length));
break; }break;
case FIFO_DATA_16BIT: case FIFO_DATA_16BIT:
{
memcpy(dat, &(((uint16 *)fifo->buffer)[fifo->max - temp_length]), temp_length * 2); 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); memcpy(&(((uint16 *)dat)[temp_length]), &(((uint16 *)fifo->buffer)[fifo->head - *length]), (*length - temp_length) * 2);
break; }break;
case FIFO_DATA_32BIT: case FIFO_DATA_32BIT:
{
memcpy(dat, &(((uint32 *)fifo->buffer)[fifo->max - temp_length]), temp_length * 4); 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); 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; break;
} }
fifo->execution |= FIFO_CLEAR; fifo_clear(fifo);
fifo_end_offset(fifo, (fifo->max - fifo->size));
fifo->size = fifo->max;
fifo->execution &= ~FIFO_CLEAR;
} }
}while(0); }while(0);
fifo->execution &= FIFO_READ;
return return_state; 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) fifo_state_enum fifo_init (fifo_struct *fifo, fifo_data_type_enum type, void *buffer_addr, uint32 size)
{ {
zf_assert(fifo != NULL); zf_assert(NULL != fifo);
fifo_state_enum return_value = FIFO_SUCCESS; fifo_state_enum return_state = FIFO_SUCCESS;
do do
{ {
if(NULL == buffer_addr)
{
return_value = FIFO_BUFFER_NULL;
break;
}
fifo->buffer = buffer_addr; fifo->buffer = buffer_addr;
fifo->execution = FIFO_IDLE; fifo->execution = FIFO_IDLE;
fifo->type = type; 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->size = size;
fifo->max = size; fifo->max = size;
}while(0); }while(0);
return return_value; return return_state;
} }

View File

@@ -40,37 +40,48 @@
typedef enum typedef enum
{ {
FIFO_SUCCESS, FIFO_SUCCESS, // FIFO <20><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>
FIFO_WRITE_UNDO, FIFO_RESET_UNDO, // FIFO <20><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>δִ<CEB4><D6B4>
FIFO_CLEAR_UNDO, FIFO_CLEAR_UNDO, // FIFO <20><><EFBFBD>ղ<EFBFBD><D5B2><EFBFBD>δִ<CEB4><D6B4>
FIFO_BUFFER_NULL, FIFO_BUFFER_NULL, // FIFO <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
FIFO_SPACE_NO_ENOUGH, FIFO_WRITE_UNDO, // FIFO д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δִ<CEB4><D6B4>
FIFO_DATA_NO_ENOUGH, FIFO_SPACE_NO_ENOUGH, // FIFO д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<D5BC><E4B2BB>
}fifo_state_enum; 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 typedef enum
{ {
FIFO_IDLE = 0x00, 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_CLEAR = 0x01, FIFO_READ_ONLY, // FIFO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ <20><><EFBFBD><EFBFBD>ȡ
FIFO_WRITE = 0x02,
FIFO_READ = 0x04,
}fifo_execution_enum;
typedef enum
{
FIFO_READ_AND_CLEAN,
FIFO_READ_ONLY,
}fifo_operation_enum; }fifo_operation_enum;
typedef enum typedef enum
{ {
FIFO_DATA_8BIT, FIFO_DATA_8BIT, // FIFO <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB> 8bit
FIFO_DATA_16BIT, FIFO_DATA_16BIT, // FIFO <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB> 16bit
FIFO_DATA_32BIT, FIFO_DATA_32BIT, // FIFO <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB> 32bit
}fifo_data_type_enum; }fifo_data_type_enum;
typedef struct typedef struct __attribute__((packed))
{ {
uint8 execution; // ִ<>в<EFBFBD><D0B2><EFBFBD> uint8 execution; // ִ<>в<EFBFBD><D0B2><EFBFBD>
fifo_data_type_enum type; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><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); fifo_state_enum fifo_init (fifo_struct *fifo, fifo_data_type_enum type, void *buffer_addr, uint32 size);
#endif #endif