Merge branch 'master' of http://git.brisky.space:441/btl143/firmware_clover
This commit is contained in:
@@ -284,6 +284,7 @@ void TIM1_UP_IRQHandler(void)
|
||||
{
|
||||
if (TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET) {
|
||||
TIM_ClearITPendingBit(TIM1, TIM_IT_Update);
|
||||
by_tiny_frame_parse_timer_handle();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,20 +5,67 @@
|
||||
PARAM_INFO Param_Data[DATA_NUM];
|
||||
soft_iic_info_struct eeprom_param;
|
||||
TYPE_UNION iic_buffer[DATA_IN_FLASH_NUM];
|
||||
|
||||
void jj_param_eeprom_init()
|
||||
uint32_t *addre[2];
|
||||
float data0 = 1.0f;
|
||||
float data1 = 1.05f;
|
||||
float data2 = 10.0f;
|
||||
float data3 = 100.0f;
|
||||
float data4 = 4.0f;
|
||||
float data5 = 66.0f;
|
||||
float data6 = 13.130f;
|
||||
float data7 = 10.0f;
|
||||
float data8 = 0.0f;
|
||||
/**
|
||||
* @brief 参数初始化注册
|
||||
*
|
||||
*/
|
||||
void jj_param_eeprom_init(void)
|
||||
{
|
||||
soft_iic_init(&eeprom_param, K24C02_DEV_ADDR, K24C02_SOFT_IIC_DELAY, K24C02_SCL_PIN, K24C02_SDA_PIN); // eeprom初始化
|
||||
// PARAM_REG(angle_Kp, &an_Kp, EFLOAT, 1, "an_P"); // 注冊
|
||||
// PARAM_REG(angle_Ki, &an_Ki, EFLOAT, 1, "an_I"); // 注冊
|
||||
// PARAM_REG(angle_Kd, &an_Kd, EFLOAT, 1, "an_D"); // 注冊
|
||||
// PARAM_REG(imgax_Kp, &im_Kp, EFLOAT, 1, "im_P"); // 注冊
|
||||
// PARAM_REG(imgax_Ki, &im_Ki, EFLOAT, 1, "im_I"); // 注冊
|
||||
// PARAM_REG(imgax_Kd, &im_Kd, EFLOAT, 1, "im_D"); // 注冊
|
||||
|
||||
PARAM_REG(angle_Kp, &data0, EFLOAT, 1, "an_P:"); // 注冊
|
||||
PARAM_REG(angle_Ki, &data1, EFLOAT, 1, "an_I:"); // 注冊
|
||||
PARAM_REG(angle_Kd, &data2, EFLOAT, 1, "an_D:"); // 注冊
|
||||
PARAM_REG(imgax_Kp, &data3, EFLOAT, 1, "im_P:"); // 注冊
|
||||
PARAM_REG(imgax_Ki, &data4, EFLOAT, 1, "im_I:"); // 注冊
|
||||
PARAM_REG(imgax_Kd, &data5, EFLOAT, 1, "im_D:");
|
||||
PARAM_REG(other , &data6, EFLOAT, 1, "add:");
|
||||
PARAM_REG(delta_x , &data7, EFLOAT, 2, "delta_x:");
|
||||
PARAM_REG(delta_y , &data8, EFLOAT, 0, "delta_y:");
|
||||
jj_param_read(); // 注冊
|
||||
}
|
||||
/**
|
||||
* @brief 参数写入
|
||||
*
|
||||
*/
|
||||
void jj_param_write(void)
|
||||
{
|
||||
for (uint8 i = 0; i < DATA_IN_FLASH_NUM; i++) {
|
||||
switch (Param_Data[i].type) {
|
||||
case EFLOAT:
|
||||
iic_buffer[i].f32 = *((float *)(Param_Data[i].p_data));
|
||||
break;
|
||||
case EUINT32:
|
||||
iic_buffer[i].u32 = *((uint32 *)(Param_Data[i].p_data));
|
||||
break;
|
||||
case EINT32:
|
||||
iic_buffer[i].s32 = *((int32 *)(Param_Data[i].p_data));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
eep_soft_iic_write_8bit_registers(&eeprom_param, (4 * i) >> 8, (4 * i), (uint8 *)&iic_buffer[i], 4);
|
||||
system_delay_ms(10);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief 参数读出
|
||||
*
|
||||
*/
|
||||
void jj_param_read(void)
|
||||
{
|
||||
for (uint8 i = 0; i < DATA_IN_FLASH_NUM; i++) {
|
||||
|
||||
soft_iic_read_8bit_registers(&eeprom_param, 4 * i, (uint8 *)&iic_buffer[i], 4);
|
||||
eep_soft_iic_read_8bit_registers(&eeprom_param, (4 * i) >> 8, (4 * i), (uint8 *)&iic_buffer[i], 4);
|
||||
switch (Param_Data[i].type) {
|
||||
case EFLOAT:
|
||||
*((float *)(Param_Data[i].p_data)) =
|
||||
@@ -38,27 +85,3 @@ void jj_param_eeprom_init()
|
||||
system_delay_ms(10);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief 参数更新
|
||||
*
|
||||
*/
|
||||
void jj_param_update()
|
||||
{
|
||||
for (uint8 i = 0; i < DATA_IN_FLASH_NUM; i++) {
|
||||
switch (Param_Data[i].type) {
|
||||
case EFLOAT:
|
||||
iic_buffer[i].f32 = *((float *)(Param_Data[i].p_data));
|
||||
break;
|
||||
case EUINT32:
|
||||
iic_buffer[i].u32 = *((uint32 *)(Param_Data[i].p_data));
|
||||
break;
|
||||
case EINT32:
|
||||
iic_buffer[i].s32 = *((int32 *)(Param_Data[i].p_data));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
soft_iic_write_8bit_registers(&eeprom_param, 4 * i, (uint8 *)&iic_buffer[i], 4);
|
||||
system_delay_ms(10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,14 +15,25 @@
|
||||
Param_Data[_data_tag_].text = _text_;
|
||||
|
||||
typedef enum {
|
||||
DATA_HEAD = -1,
|
||||
angle_Kp,
|
||||
|
||||
Page1_head=0,
|
||||
|
||||
angle_Kp=Page1_head,
|
||||
angle_Ki,
|
||||
angle_Kd,
|
||||
imgax_Kp,
|
||||
other,
|
||||
|
||||
Page2_head,
|
||||
// 第二页参数
|
||||
imgax_Kp=Page2_head,
|
||||
imgax_Ki,
|
||||
imgax_Kd,
|
||||
|
||||
Page3_head,
|
||||
DATA_IN_FLASH_NUM,
|
||||
|
||||
delta_x,
|
||||
delta_y,
|
||||
DATA_NUM,
|
||||
} data_tag_t;
|
||||
|
||||
@@ -42,14 +53,15 @@ typedef union{
|
||||
typedef struct {
|
||||
void *p_data;
|
||||
ENUM_TYPE type;
|
||||
uint8_t cmd;
|
||||
uint8_t cmd;//01:仅存储 00:仅显示 02:传输并显示
|
||||
char *text;
|
||||
} PARAM_INFO;
|
||||
|
||||
extern uint32_t * addre[2];
|
||||
extern soft_iic_info_struct eeprom_param;
|
||||
extern PARAM_INFO Param_Data[DATA_NUM];
|
||||
extern TYPE_UNION iic_buffer[DATA_IN_FLASH_NUM];
|
||||
void jj_param_eeprom_init();
|
||||
void jj_param_update();
|
||||
void jj_param_show();
|
||||
void jj_param_eeprom_init(void);
|
||||
void jj_param_write(void);
|
||||
void jj_param_read(void);
|
||||
extern float data7;
|
||||
#endif
|
||||
34
app/main.c
34
app/main.c
@@ -57,16 +57,15 @@ int main(void)
|
||||
ips200_init(IPS200_TYPE_SPI);
|
||||
|
||||
by_led_init();
|
||||
by_buzzer_init();
|
||||
// by_buzzer_init();
|
||||
by_button_init();
|
||||
|
||||
// jj_bt_init();
|
||||
// jj_param_eeprom_init();
|
||||
jj_bt_init();
|
||||
jj_param_eeprom_init();
|
||||
|
||||
Page_Init();
|
||||
|
||||
// pit_ms_init(TIM6_PIT, 2);
|
||||
// pit_ms_init(TIM1_PIT, 2);
|
||||
pit_ms_init(TIM1_PIT, 1);
|
||||
|
||||
by_tiny_frame_init();
|
||||
printf("start running\r\n");
|
||||
@@ -79,7 +78,7 @@ int main(void)
|
||||
|
||||
frame_now.cmd = 0x06;
|
||||
frame_now.data = 0x19260817;
|
||||
frame_now.reg_addr = 0x4059;
|
||||
frame_now.reg_addr = 0x00;
|
||||
frame_now.slave_id = 0x0D;
|
||||
/** 测试完成后移除 **/
|
||||
|
||||
@@ -87,13 +86,11 @@ int main(void)
|
||||
by_tiny_frame_read(0x0D, 0x4059, &data_test);
|
||||
while (1) {
|
||||
Page_Run();
|
||||
by_buzzer_run();
|
||||
// by_buzzer_run();
|
||||
|
||||
/** 测试完成后移除 **/
|
||||
by_tiny_frame_run();
|
||||
// by_tiny_frame_pack_send(&frame_now);
|
||||
by_tiny_frame_pack_send(&frame_now);
|
||||
system_delay_ms(10);
|
||||
by_tiny_frame_parse_timer_handle();
|
||||
/** 测试完成后移除 **/
|
||||
|
||||
if (mt9v03x_finish_flag) {
|
||||
@@ -103,14 +100,15 @@ int main(void)
|
||||
// ips200_show_gray_image(0, 0, mt9v03x_image_copy[0], MT9V03X_W, MT9V03X_H, MT9V03X_W, MT9V03X_H, 0);
|
||||
mt9v03x_finish_flag = 0;
|
||||
by_led_info_blink();
|
||||
state_type = COMMON_STATE;
|
||||
img_processing();
|
||||
get_corners();
|
||||
aim_distance = COMMON_AIM;
|
||||
tracking();
|
||||
ElementJudge();
|
||||
ElementRun();
|
||||
MidLineTrack();
|
||||
// state_type = COMMON_STATE;
|
||||
// img_processing();
|
||||
// get_corners();
|
||||
// aim_distance = COMMON_AIM;
|
||||
// tracking();
|
||||
// ElementJudge();
|
||||
// ElementRun();
|
||||
// MidLineTrack();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,13 @@
|
||||
|
||||
PAGE_LIST pagelist[page_max];
|
||||
static uint8_t page_busy = 0;
|
||||
static int8_t now_page = page_menu;
|
||||
static int8_t new_page = page_menu;
|
||||
static int8_t now_page = page_menu;
|
||||
|
||||
int8_t Get_new_page(void)
|
||||
{
|
||||
return new_page;
|
||||
}
|
||||
/**
|
||||
* @brief 注册一个基本页面,包含一个初始化函数,循环函数,退出函数,事件函数
|
||||
* @param pageID: 页面编号
|
||||
@@ -17,11 +21,11 @@ static int8_t new_page = page_menu;
|
||||
* @param eventCallback: 事件函数回调
|
||||
* @retval 无
|
||||
*/
|
||||
void Page_Register(uint8_t pageID, char *pageText,
|
||||
void Page_Register(uint8_t pageID,
|
||||
CallbackFunction_t setupCallback, CallbackFunction_t loopCallback,
|
||||
CallbackFunction_t exitCallback, EventFunction_t eventCallback)
|
||||
{
|
||||
pagelist[pageID].Text = pageText;
|
||||
|
||||
pagelist[pageID].SetupCallback = setupCallback;
|
||||
pagelist[pageID].LoopCallback = loopCallback;
|
||||
pagelist[pageID].ExitCallback = exitCallback;
|
||||
@@ -123,9 +127,11 @@ void Page_Run(void)
|
||||
*/
|
||||
void Page_Init(void)
|
||||
{
|
||||
PAGE_REG(page_menu);
|
||||
PAGE_REG(page_rtcam);
|
||||
PAGE_REG(page_param);
|
||||
PAGE_REG(page_menu, "main");
|
||||
PAGE_REG(page_rtcam, "rtcam");
|
||||
PAGE_REG(page_param1, "Param1");
|
||||
PAGE_REG(page_param2, "param2");
|
||||
PAGE_REG(page_dparam, "dparam");
|
||||
// PAGE_REG(page_argv);
|
||||
// PAGE_REG(page_sys);
|
||||
// PAGE_REG(page_run);
|
||||
|
||||
@@ -20,7 +20,9 @@ enum PageID {
|
||||
//......
|
||||
page_menu,
|
||||
page_rtcam,
|
||||
page_param,
|
||||
page_param1,
|
||||
page_param2,
|
||||
page_dparam,
|
||||
// page_argv,
|
||||
// page_sys,
|
||||
// page_run,
|
||||
@@ -46,13 +48,15 @@ typedef struct {
|
||||
} PAGE_LIST;
|
||||
|
||||
// 页面注册函数
|
||||
#define PAGE_REG(name) \
|
||||
#define PAGE_REG(_name_, _text_) \
|
||||
do { \
|
||||
extern void PageRegister_##name(unsigned char pageID); \
|
||||
PageRegister_##name(name); \
|
||||
} while (0)
|
||||
extern void PageRegister_##_name_(unsigned char pageID); \
|
||||
PageRegister_##_name_(_name_); \
|
||||
} while (0); \
|
||||
pagelist[_name_].Text = _text_ ;
|
||||
|
||||
void Page_Register(uint8_t pageID, char *pageText,
|
||||
|
||||
void Page_Register(uint8_t pageID,
|
||||
CallbackFunction_t setupCallback, CallbackFunction_t loopCallback,
|
||||
CallbackFunction_t exitCallback, EventFunction_t eventCallback);
|
||||
|
||||
@@ -63,7 +67,7 @@ void Page_OpenCurrentPage(void);
|
||||
uint8_t Page_GetStatus(void);
|
||||
void Page_Run(void);
|
||||
void Page_Init(void);
|
||||
int8_t Get_new_page(void);
|
||||
|
||||
extern PAGE_LIST pagelist[page_max];
|
||||
|
||||
#endif
|
||||
|
||||
72
app/page/page_dparam.c
Normal file
72
app/page/page_dparam.c
Normal file
@@ -0,0 +1,72 @@
|
||||
#include "zf_common_headfile.h"
|
||||
#include "page_ui_widget.h"
|
||||
#include "page.h"
|
||||
#include "jj_param.h"
|
||||
// #define LINE_HEAD 1
|
||||
// #define LINE_END 7
|
||||
// static int8_t Curser = LINE_HEAD; // 定义光标位置
|
||||
// static int8_t Curser_Last = LINE_HEAD; // 定义光标位置
|
||||
/***************************************************************************************
|
||||
*
|
||||
* 以下为页面模板函数
|
||||
*
|
||||
***************************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief 页面初始化事件
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Setup()
|
||||
{
|
||||
ips200_clear();
|
||||
// 显示参数名称
|
||||
ips200_show_string(0, 0, "Dparam");
|
||||
|
||||
ips200_show_string(20, 18 + 2, (Param_Data[delta_x].text));
|
||||
ips200_show_string(20, 18 + 20, (Param_Data[delta_y].text));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面退出事件
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Exit()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面循环执行的内容
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Loop()
|
||||
{
|
||||
// 刷新参数数值
|
||||
ips200_show_float(90, 18 + 2, *((float *)(Param_Data[delta_x].p_data)), 4, 5);
|
||||
ips200_show_float(90, 18 + 20, *((float *)(Param_Data[delta_x].p_data)), 4, 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面事件
|
||||
* @param btn:发出事件的按键
|
||||
* @param event:事件编号
|
||||
* @retval 无
|
||||
*/
|
||||
static void Event(page_event event)
|
||||
{
|
||||
if (page_event_press_long == event) {
|
||||
Page_Shift(page_menu);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面注册函数
|
||||
*
|
||||
* @param pageID
|
||||
*/
|
||||
void PageRegister_page_dparam(unsigned char pageID)
|
||||
{
|
||||
Page_Register(pageID, Setup, Loop, Exit, Event);
|
||||
}
|
||||
@@ -57,9 +57,9 @@ static void Event(page_event event)
|
||||
Curser_Last = Curser;
|
||||
|
||||
if (page_event_forward == event) {
|
||||
Curser--; // 光标上移
|
||||
Curser++; // 光标上移
|
||||
} else if (page_event_backward == event) {
|
||||
Curser++; // 光标下移
|
||||
Curser--; // 光标下移
|
||||
} else if (page_event_press_short == event) {
|
||||
if (page_max > Curser && page_menu < Curser) {
|
||||
Page_Shift(Curser); // 切换到光标选中的页面
|
||||
@@ -82,7 +82,7 @@ static void Event(page_event event)
|
||||
*/
|
||||
void PageRegister_page_menu(unsigned char pageID)
|
||||
{
|
||||
Page_Register(pageID, Text, Setup, Loop, Exit, Event);
|
||||
Page_Register(pageID, Setup, Loop, Exit, Event);
|
||||
}
|
||||
|
||||
/***************************************************************************************
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
#include "jj_param.h"
|
||||
#include "page_ui_widget.h"
|
||||
#include "page.h"
|
||||
|
||||
#define LINE_HEAD 0
|
||||
#define LINE_END DATA_NUM - 2
|
||||
static char Text[] = "Param";
|
||||
int event_flag = 0;
|
||||
int32_t index_power = 0;
|
||||
static int8_t Curser = LINE_HEAD; // 定义光标位置
|
||||
static int8_t Curser_Last = LINE_HEAD; // 定义光标位置
|
||||
void jj_param_show();
|
||||
/***************************************************************************************
|
||||
*
|
||||
* 以下为页面模板函数
|
||||
*
|
||||
***************************************************************************************/
|
||||
/**
|
||||
* @brief 页面初始化事件
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Setup()
|
||||
{
|
||||
ips200_clear();
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
for (int16 i = 0; i < DATA_NUM - 1; i++) {
|
||||
ips200_show_string(10, i * 18 + 2, Param_Data[i].text);
|
||||
if (Param_Data[i].type == EINT32)
|
||||
ips200_show_int(50, i * 18 + 2, *((int32 *)(Param_Data[i].p_data)), 5);
|
||||
else if (Param_Data[i].type == EFLOAT)
|
||||
ips200_show_float(50, i * 18 + 2, *((float *)(Param_Data[i].p_data)), 4, 5);
|
||||
}
|
||||
ips200_show_int(50, (DATA_NUM-1)* 18 + 2, index_power, 5);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面退出事件
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Exit()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面循环执行的内容
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Loop()
|
||||
{
|
||||
}
|
||||
/**
|
||||
* @brief 页面事件
|
||||
* @param btn:发出事件的按键
|
||||
* @param event:事件编号
|
||||
* @retval 无
|
||||
*/
|
||||
static void Event(page_event event)
|
||||
{
|
||||
|
||||
if (0 == event_flag) {
|
||||
|
||||
Curser_Last = Curser;
|
||||
if (page_event_forward == event) {
|
||||
Curser--; // 光标上移
|
||||
} else if (page_event_backward == event) {
|
||||
Curser++; // 光标下移
|
||||
} else if (page_event_press_short == event) {
|
||||
event_flag = 1; // 选中参数
|
||||
Print_Curser(Curser, Curser_Last, RGB565_RED);
|
||||
return;
|
||||
} else if (page_event_press_long == event) {
|
||||
jj_param_update();
|
||||
Page_Shift(page_menu);
|
||||
return;
|
||||
}
|
||||
if (Curser < LINE_HEAD) {
|
||||
Curser = LINE_END;
|
||||
} else if (Curser > LINE_END) {
|
||||
Curser = LINE_HEAD;
|
||||
}
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
} else if (1 == event_flag) {
|
||||
if (page_event_forward == event) {
|
||||
if (Param_Data[Curser].type == EFLOAT) {
|
||||
*((float *)(Param_Data[Curser].p_data)) += powf(10.0f,(float)index_power);
|
||||
} else if (Param_Data[Curser].type == EINT32) {
|
||||
*((int32 *)(Param_Data[Curser].p_data)) += 1;
|
||||
} else if (Param_Data[Curser].type == EUINT32) {
|
||||
*((uint32 *)(Param_Data[Curser].p_data)) += 1;
|
||||
}
|
||||
} else if (page_event_backward == event) {
|
||||
if (Param_Data[Curser].type == EFLOAT) {
|
||||
*((float *)(Param_Data[Curser].p_data)) -=powf(10.0f,(float)index_power);
|
||||
} else if (Param_Data[Curser].type == EINT32) {
|
||||
*((int32 *)(Param_Data[Curser].p_data)) -= 1;
|
||||
} else if (Param_Data[Curser].type == EUINT32) {
|
||||
*((uint32 *)(Param_Data[Curser].p_data)) -= 1;
|
||||
}
|
||||
} else if (page_event_press_short == event) {
|
||||
index_power++;
|
||||
if (index_power > 2) {
|
||||
index_power = -2;
|
||||
}
|
||||
ips200_show_int(50, (DATA_NUM-1)* 18 + 2, index_power, 5);
|
||||
} else if (page_event_press_long == event) {
|
||||
event_flag = 0;
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
}
|
||||
jj_param_show();
|
||||
}
|
||||
}
|
||||
void jj_param_show()
|
||||
{
|
||||
if (EINT32 == Param_Data[Curser].type)
|
||||
ips200_show_int(50, Curser * 18 + 2, *((int32 *)(Param_Data[Curser].p_data)), 5);
|
||||
else if (EUINT32 == Param_Data[Curser].type)
|
||||
ips200_show_uint(50, Curser * 18 + 2, *((int32 *)(Param_Data[Curser].p_data)), 5);
|
||||
else if (EFLOAT == Param_Data[Curser].type)
|
||||
ips200_show_float(50, Curser * 18 + 2, *((float *)(Param_Data[Curser].p_data)), 4, 5);
|
||||
}
|
||||
/**
|
||||
* @brief 页面注册函数
|
||||
*
|
||||
* @param pageID
|
||||
*/
|
||||
void PageRegister_page_param(unsigned char pageID)
|
||||
{
|
||||
Page_Register(pageID, Text, Setup, Loop, Exit, Event);
|
||||
}
|
||||
@@ -5,8 +5,6 @@
|
||||
#define LINE_HEAD 11
|
||||
#define LINE_END 16
|
||||
|
||||
static char Text[] = "RealTime Image";
|
||||
|
||||
static int8_t Curser = LINE_HEAD; // 定义光标位置
|
||||
static int8_t Curser_Last = LINE_HEAD; // 定义光标位置
|
||||
/***************************************************************************************
|
||||
@@ -81,7 +79,7 @@ static void Event(page_event event)
|
||||
*/
|
||||
void PageRegister_page_rtcam(unsigned char pageID)
|
||||
{
|
||||
Page_Register(pageID, Text, Setup, Loop, Exit, Event);
|
||||
Page_Register(pageID, Setup, Loop, Exit, Event);
|
||||
}
|
||||
|
||||
/***************************************************************************************
|
||||
|
||||
160
app/page/page_sparam1.c
Normal file
160
app/page/page_sparam1.c
Normal file
@@ -0,0 +1,160 @@
|
||||
#include "jj_param.h"
|
||||
#include "page_ui_widget.h"
|
||||
#include "page.h"
|
||||
#include <math.h>
|
||||
|
||||
#define LINE_HEAD 1
|
||||
|
||||
static int16 pafrist;
|
||||
static int16 paend;
|
||||
static int16 palong;
|
||||
static int event_flag = 0;
|
||||
static int32_t index_power = 0;
|
||||
static int8_t Curser = LINE_HEAD; // 定义光标位置
|
||||
static int8_t Curser_Last = LINE_HEAD; // 定义光标位置
|
||||
/***************************************************************************************
|
||||
*
|
||||
* 以下为页面模板函数
|
||||
*
|
||||
***************************************************************************************/
|
||||
/**
|
||||
* @brief 页面初始化事件
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Setup()
|
||||
{
|
||||
ips200_clear();
|
||||
|
||||
if (Get_new_page() == page_param1) {
|
||||
pafrist = 0;
|
||||
paend = Page2_head;
|
||||
ips200_show_string(0, 0, "Param1");
|
||||
} else if (Get_new_page() == page_param2) {
|
||||
pafrist = Page2_head;
|
||||
paend = Page3_head;
|
||||
ips200_show_string(0, 0, "Param2");
|
||||
}
|
||||
|
||||
palong = paend - pafrist;
|
||||
if (Curser < LINE_HEAD) {
|
||||
Curser = palong;
|
||||
} else if (Curser > palong) {
|
||||
Curser = LINE_HEAD;
|
||||
}
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
for (int16 i = 0; i < palong; i++) {
|
||||
ips200_show_string(20, i * 18 + 20, Param_Data[i + pafrist].text);
|
||||
if (Param_Data[i].type == EINT32)
|
||||
ips200_show_int(60, i * 18 + 20, *((int32 *)(Param_Data[i + pafrist].p_data)), 5);
|
||||
else if (Param_Data[i].type == EFLOAT)
|
||||
ips200_show_float(60, i * 18 + 20, *((float *)(Param_Data[i + pafrist].p_data)), 4, 5);
|
||||
}
|
||||
ips200_show_int(50, palong * 18 + 20, index_power, 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面退出事件
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Exit()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面循环执行的内容
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Loop()
|
||||
{
|
||||
}
|
||||
/**
|
||||
* @brief 页面事件
|
||||
* @param btn:发出事件的按键
|
||||
* @param event:事件编号
|
||||
* @retval 无
|
||||
*/
|
||||
static void Event(page_event event)
|
||||
{
|
||||
|
||||
if (0 == event_flag) {
|
||||
|
||||
Curser_Last = Curser;
|
||||
if (page_event_forward == event) {
|
||||
Curser++; // 光标上移
|
||||
} else if (page_event_backward == event) {
|
||||
Curser--; // 光标下移
|
||||
} else if (page_event_press_short == event) {
|
||||
event_flag = 1; // 选中参数
|
||||
Print_Curser(Curser, Curser_Last, RGB565_RED);
|
||||
return;
|
||||
} else if (page_event_press_long == event) {
|
||||
jj_param_write();
|
||||
Page_Shift(page_menu);
|
||||
return;
|
||||
}
|
||||
if (Curser < LINE_HEAD) {
|
||||
Curser = palong;
|
||||
} else if (Curser > palong) {
|
||||
Curser = LINE_HEAD;
|
||||
}
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
} else if (1 == event_flag) {
|
||||
if (page_event_forward == event) {
|
||||
switch (Param_Data[Curser + pafrist - 1].type) {
|
||||
case EFLOAT:
|
||||
*((float *)(Param_Data[Curser + pafrist - 1].p_data)) += powf(10, index_power);
|
||||
break;
|
||||
case EINT32:
|
||||
*((int32 *)(Param_Data[Curser + pafrist - 1].p_data)) += 1;
|
||||
break;
|
||||
case EUINT32:
|
||||
*((uint32 *)(Param_Data[Curser + pafrist - 1].p_data)) += 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (page_event_backward == event) {
|
||||
switch (Param_Data[Curser + pafrist - 1].type) {
|
||||
case EFLOAT:
|
||||
*((float *)(Param_Data[Curser + pafrist - 1].p_data)) -= powf(10.0f, (float)index_power);
|
||||
break;
|
||||
case EINT32:
|
||||
*((int32 *)(Param_Data[Curser + pafrist - 1].p_data)) -= 1;
|
||||
break;
|
||||
case EUINT32:
|
||||
*((uint32 *)(Param_Data[Curser + pafrist - 1].p_data)) -= 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (page_event_press_short == event) {
|
||||
index_power++;
|
||||
if (index_power > 2) {
|
||||
index_power = -2;
|
||||
}
|
||||
ips200_show_int(50, palong * 18 + 20, index_power, 5);
|
||||
} else if (page_event_press_long == event) {
|
||||
event_flag = 0;
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
}
|
||||
if (EINT32 == Param_Data[Curser + pafrist - 1].type)
|
||||
ips200_show_int(60, Curser * 18 + 2, *((int32 *)(Param_Data[Curser + pafrist - 1].p_data)), 5);
|
||||
else if (EUINT32 == Param_Data[Curser + pafrist - 1].type)
|
||||
ips200_show_uint(60, Curser * 18 + 2, *((int32 *)(Param_Data[Curser + pafrist - 1].p_data)), 5);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面注册函数
|
||||
*
|
||||
* @param pageID
|
||||
*/
|
||||
void PageRegister_page_param1(unsigned char pageID)
|
||||
{
|
||||
Page_Register(pageID, Setup, Loop, Exit, Event);
|
||||
}
|
||||
160
app/page/page_sparam2.c
Normal file
160
app/page/page_sparam2.c
Normal file
@@ -0,0 +1,160 @@
|
||||
#include "jj_param.h"
|
||||
#include "page_ui_widget.h"
|
||||
#include "page.h"
|
||||
#include <math.h>
|
||||
|
||||
#define LINE_HEAD 1
|
||||
|
||||
static int16 pafrist;
|
||||
static int16 paend;
|
||||
static int16 palong;
|
||||
static int event_flag = 0;
|
||||
static int32_t index_power = 0;
|
||||
static int8_t Curser = LINE_HEAD; // 定义光标位置
|
||||
static int8_t Curser_Last = LINE_HEAD; // 定义光标位置
|
||||
/***************************************************************************************
|
||||
*
|
||||
* 以下为页面模板函数
|
||||
*
|
||||
***************************************************************************************/
|
||||
/**
|
||||
* @brief 页面初始化事件
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Setup()
|
||||
{
|
||||
ips200_clear();
|
||||
|
||||
if (Get_new_page() == page_param1) {
|
||||
pafrist = 0;
|
||||
paend = Page2_head;
|
||||
ips200_show_string(0, 0, "Param1");
|
||||
} else if (Get_new_page() == page_param2) {
|
||||
pafrist = Page2_head;
|
||||
paend = Page3_head;
|
||||
ips200_show_string(0, 0, "Param2");
|
||||
}
|
||||
|
||||
palong = paend - pafrist;
|
||||
if (Curser < LINE_HEAD) {
|
||||
Curser = palong;
|
||||
} else if (Curser > palong) {
|
||||
Curser = LINE_HEAD;
|
||||
}
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
for (int16 i = 0; i < palong; i++) {
|
||||
ips200_show_string(20, i * 18 + 20, Param_Data[i + pafrist].text);
|
||||
if (Param_Data[i].type == EINT32)
|
||||
ips200_show_int(60, i * 18 + 20, *((int32 *)(Param_Data[i + pafrist].p_data)), 5);
|
||||
else if (Param_Data[i].type == EFLOAT)
|
||||
ips200_show_float(60, i * 18 + 20, *((float *)(Param_Data[i + pafrist].p_data)), 4, 5);
|
||||
}
|
||||
ips200_show_int(50, palong * 18 + 20, index_power, 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面退出事件
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Exit()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面循环执行的内容
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Loop()
|
||||
{
|
||||
}
|
||||
/**
|
||||
* @brief 页面事件
|
||||
* @param btn:发出事件的按键
|
||||
* @param event:事件编号
|
||||
* @retval 无
|
||||
*/
|
||||
static void Event(page_event event)
|
||||
{
|
||||
|
||||
if (0 == event_flag) {
|
||||
|
||||
Curser_Last = Curser;
|
||||
if (page_event_forward == event) {
|
||||
Curser++; // 光标上移
|
||||
} else if (page_event_backward == event) {
|
||||
Curser--; // 光标下移
|
||||
} else if (page_event_press_short == event) {
|
||||
event_flag = 1; // 选中参数
|
||||
Print_Curser(Curser, Curser_Last, RGB565_RED);
|
||||
return;
|
||||
} else if (page_event_press_long == event) {
|
||||
jj_param_write();
|
||||
Page_Shift(page_menu);
|
||||
return;
|
||||
}
|
||||
if (Curser < LINE_HEAD) {
|
||||
Curser = palong;
|
||||
} else if (Curser > palong) {
|
||||
Curser = LINE_HEAD;
|
||||
}
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
} else if (1 == event_flag) {
|
||||
if (page_event_forward == event) {
|
||||
switch (Param_Data[Curser + pafrist - 1].type) {
|
||||
case EFLOAT:
|
||||
*((float *)(Param_Data[Curser + pafrist - 1].p_data)) += powf(10, index_power);
|
||||
break;
|
||||
case EINT32:
|
||||
*((int32 *)(Param_Data[Curser + pafrist - 1].p_data)) += 1;
|
||||
break;
|
||||
case EUINT32:
|
||||
*((uint32 *)(Param_Data[Curser + pafrist - 1].p_data)) += 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (page_event_backward == event) {
|
||||
switch (Param_Data[Curser + pafrist - 1].type) {
|
||||
case EFLOAT:
|
||||
*((float *)(Param_Data[Curser + pafrist - 1].p_data)) -= powf(10.0f, (float)index_power);
|
||||
break;
|
||||
case EINT32:
|
||||
*((int32 *)(Param_Data[Curser + pafrist - 1].p_data)) -= 1;
|
||||
break;
|
||||
case EUINT32:
|
||||
*((uint32 *)(Param_Data[Curser + pafrist - 1].p_data)) -= 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (page_event_press_short == event) {
|
||||
index_power++;
|
||||
if (index_power > 2) {
|
||||
index_power = -2;
|
||||
}
|
||||
ips200_show_int(50, palong * 18 + 20, index_power, 5);
|
||||
} else if (page_event_press_long == event) {
|
||||
event_flag = 0;
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
}
|
||||
if (EINT32 == Param_Data[Curser + pafrist - 1].type)
|
||||
ips200_show_int(60, Curser * 18 + 2, *((int32 *)(Param_Data[Curser + pafrist - 1].p_data)), 5);
|
||||
else if (EUINT32 == Param_Data[Curser + pafrist - 1].type)
|
||||
ips200_show_uint(60, Curser * 18 + 2, *((int32 *)(Param_Data[Curser + pafrist - 1].p_data)), 5);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面注册函数
|
||||
*
|
||||
* @param pageID
|
||||
*/
|
||||
void PageRegister_page_param2(unsigned char pageID)
|
||||
{
|
||||
Page_Register(pageID, Setup, Loop, Exit, Event);
|
||||
}
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "by_tiny_frame_parse.h"
|
||||
#include "by_tiny_frame_pack.h"
|
||||
|
||||
#include "jj_param.h"
|
||||
|
||||
void by_tiny_frame_read_write_run(void)
|
||||
{
|
||||
// empty
|
||||
@@ -13,31 +15,31 @@ void by_tiny_frame_read_write_run(void)
|
||||
|
||||
void by_tiny_frame_read_write_handle(by_tf_parse_frame_t frame_s, uint8_t status)
|
||||
{
|
||||
by_tf_pack_frame_t frame_pack_s;
|
||||
// by_tf_pack_frame_t frame_pack_s;
|
||||
|
||||
frame_pack_s.slave_id = BY_TF_DEVICE_SLAVE_ADDRESS;
|
||||
frame_pack_s.cmd = frame_s.cmd;
|
||||
frame_pack_s.reg_addr = frame_s.reg_addr;
|
||||
// frame_pack_s.slave_id = BY_TF_DEVICE_SLAVE_ADDRESS;
|
||||
// frame_pack_s.cmd = frame_s.cmd;
|
||||
// frame_pack_s.reg_addr = frame_s.reg_addr;
|
||||
|
||||
if (status) {
|
||||
// 接收出错,一般为 CRC 校验错误
|
||||
return;
|
||||
}
|
||||
// if (status) {
|
||||
// // 接收出错,一般为 CRC 校验错误
|
||||
// return;
|
||||
// }
|
||||
|
||||
switch (frame_s.cmd) {
|
||||
case 0x03:
|
||||
// 添加查询接口,操作完成后应答
|
||||
frame_pack_s.data = 0XFFFFFFFF; // 示例
|
||||
by_tiny_frame_pack_send(&frame_pack_s);
|
||||
break;
|
||||
case 0x06:
|
||||
// 添加写入接口,操作完成后应答
|
||||
frame_pack_s.data = frame_s.data;
|
||||
by_tiny_frame_pack_send(&frame_pack_s);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// switch (frame_s.cmd) {
|
||||
// case 0x03:
|
||||
// // 添加查询接口,操作完成后应答,主机接收,即读取
|
||||
// frame_pack_s.data =(uint32_t)(addre[frame_pack_s.reg_addr]);
|
||||
// by_tiny_frame_pack_send(&frame_pack_s);
|
||||
// break;
|
||||
// case 0x06:
|
||||
// // 添加写入接口,操作完成后应答,主机发送,即写入
|
||||
// *addre[frame_pack_s.reg_addr] = frame_pack_s.data;
|
||||
// by_tiny_frame_pack_send(&frame_pack_s);
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
|
||||
#if (BY_TF_DEBUG)
|
||||
printf("****** EXECUTE CMD SUCCESSFUL ******\r\n");
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
//====================================================<3D><><EFBFBD><EFBFBD> IIC <20><><EFBFBD><EFBFBD>====================================================
|
||||
#define K24C02_SOFT_IIC_DELAY (500) // <20><><EFBFBD><EFBFBD> IIC <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> <20><>ֵԽС IIC ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD>
|
||||
#define K24C02_SCL_PIN (D13) // <20><><EFBFBD><EFBFBD> IIC SCL <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> K24C02 <20><> SCL <20><><EFBFBD><EFBFBD>
|
||||
#define K24C02_SDA_PIN (D14) // <20><><EFBFBD><EFBFBD> IIC SDA <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> K24C02 <20><> SDA <20><><EFBFBD><EFBFBD>
|
||||
#define K24C02_SDA_PIN (D12) // <20><><EFBFBD><EFBFBD> IIC SDA <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> K24C02 <20><> SDA <20><><EFBFBD><EFBFBD>
|
||||
//====================================================<3D><><EFBFBD><EFBFBD> IIC <20><><EFBFBD><EFBFBD>====================================================
|
||||
#else
|
||||
//====================================================Ӳ<><D3B2> IIC <20><><EFBFBD><EFBFBD>====================================================
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
// <20><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD><DDBA><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB>
|
||||
#define MT9V03X_UD_OFFSET_DEF (0 ) // ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD> <20><>ֵ <20><>ƫ<EFBFBD><C6AB> <20><>ֵ <20><>ƫ<EFBFBD><C6AB> <20><>Ϊ 120 240 480 ʱ<><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB>
|
||||
// <20><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD><DDBA><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB>
|
||||
#define MT9V03X_GAIN_DEF (32 ) // ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>Χ [16-64] <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>̶<EFBFBD><CCB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¸ı<C2B8>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̶<EFBFBD>
|
||||
#define MT9V03X_GAIN_DEF (64 ) // ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>Χ [16-64] <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>̶<EFBFBD><CCB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¸ı<C2B8>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̶<EFBFBD>
|
||||
#define MT9V03X_PCLK_MODE_DEF (1 ) // <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ģʽ <20><>Χ [0-1] Ĭ<>ϣ<EFBFBD>0 <20><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>[0<><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>]
|
||||
// ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ 0<><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9> CH32V307 <20><> DVP <20>ӿڻ<D3BF> STM32 <20><> DCMI <20>ӿڲɼ<DAB2><C9BC><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>Ϊ 1
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> MT9V034 V1.5 <20>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>ϰ汾֧<E6B1BE>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
@@ -709,3 +709,33 @@ void soft_iic_init (soft_iic_info_struct *soft_iic_obj, uint8 addr, uint32 delay
|
||||
gpio_init(scl_pin, GPO, GPIO_HIGH, GPO_PUSH_PULL); // <20><>ȡ<EFBFBD><C8A1>ӦIO<49><4F><EFBFBD><EFBFBD> AF<41><46><EFBFBD>ܱ<EFBFBD><DCB1><EFBFBD>
|
||||
gpio_init(sda_pin, GPO, GPIO_HIGH, GPO_OPEN_DTAIN); // <20><>ȡ<EFBFBD><C8A1>ӦIO<49><4F><EFBFBD><EFBFBD> AF<41><46><EFBFBD>ܱ<EFBFBD><DCB1><EFBFBD>
|
||||
}
|
||||
void eep_soft_iic_read_8bit_registers (soft_iic_info_struct *soft_iic_obj, const uint8 register_name_h, const uint8 register_name_l, uint8 *data, uint32 len)
|
||||
{
|
||||
zf_assert(soft_iic_obj != NULL);
|
||||
zf_assert(data != NULL);
|
||||
soft_iic_start(soft_iic_obj);
|
||||
soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1);
|
||||
soft_iic_send_data(soft_iic_obj, register_name_h);
|
||||
soft_iic_send_data(soft_iic_obj, register_name_l);
|
||||
soft_iic_start(soft_iic_obj);
|
||||
soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
|
||||
while(len --)
|
||||
{
|
||||
*data ++ = soft_iic_read_data(soft_iic_obj, len == 0);
|
||||
}
|
||||
soft_iic_stop(soft_iic_obj);
|
||||
}
|
||||
void eep_soft_iic_write_8bit_registers (soft_iic_info_struct *soft_iic_obj, const uint8 register_name_h,const uint8 register_name_l, const uint8 *data, uint32 len)
|
||||
{
|
||||
zf_assert(soft_iic_obj != NULL);
|
||||
zf_assert(data != NULL);
|
||||
soft_iic_start(soft_iic_obj);
|
||||
soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1);
|
||||
soft_iic_send_data(soft_iic_obj, register_name_h);
|
||||
soft_iic_send_data(soft_iic_obj, register_name_l);
|
||||
while(len --)
|
||||
{
|
||||
soft_iic_send_data(soft_iic_obj, *data ++);
|
||||
}
|
||||
soft_iic_stop(soft_iic_obj);
|
||||
}
|
||||
@@ -36,7 +36,6 @@
|
||||
#ifndef _zf_driver_soft_iic_h_
|
||||
#define _zf_driver_soft_iic_h_
|
||||
|
||||
|
||||
#include "zf_driver_gpio.h"
|
||||
|
||||
typedef struct
|
||||
@@ -79,5 +78,6 @@ uint8 soft_iic_sccb_read_register (soft_iic_info_struct *soft_iic_obj,
|
||||
|
||||
void soft_iic_init(soft_iic_info_struct *soft_iic_obj, uint8 addr, uint32 delay, gpio_pin_enum scl_pin, gpio_pin_enum sda_pin);
|
||||
|
||||
void eep_soft_iic_write_8bit_registers(soft_iic_info_struct *soft_iic_obj, const uint8 register_name_h, const uint8 register_name_l, const uint8 *data, uint32 len);
|
||||
void eep_soft_iic_read_8bit_registers(soft_iic_info_struct *soft_iic_obj, const uint8 register_name_h, const uint8 register_name_l, uint8 *data, uint32 len);
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user