70 lines
1.5 KiB
C
70 lines
1.5 KiB
C
|
|
#include "app_soft.h"
|
|||
|
|
#include "app_scan.h"
|
|||
|
|
#include "bsp_flash.h"
|
|||
|
|
#include "string.h"
|
|||
|
|
|
|||
|
|
#pragma pack (1)
|
|||
|
|
typedef struct
|
|||
|
|
{
|
|||
|
|
uint8_t ax;
|
|||
|
|
uint8_t ay;
|
|||
|
|
uint16_t compensation_rate;
|
|||
|
|
}sort_value_struct;
|
|||
|
|
#pragma pack ()
|
|||
|
|
|
|||
|
|
|
|||
|
|
uint8_t scan_X_line[] = {0,1,2,3,4,5,6,7,8,9,10,11};
|
|||
|
|
uint8_t scan_Y_line[] = {0,1,2,3,4,5,6,7,8,9,10,11};
|
|||
|
|
|
|||
|
|
rank_frame_struct ranks;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>˫·adc<64><63>
|
|||
|
|
int read_rank_flash(rank_frame_struct *params){
|
|||
|
|
uint32_t *head = (uint32_t*)RANKS_ADDRESS;
|
|||
|
|
uint32_t *tail = (uint32_t*)(RANKS_ADDRESS + sizeof(rank_frame_struct) - 4);
|
|||
|
|
|
|||
|
|
if(*head == RANKS_HEAD && *tail == RANKS_TAIL)
|
|||
|
|
{
|
|||
|
|
memcpy((uint32_t *)params, head, sizeof(rank_frame_struct));
|
|||
|
|
return 1;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return -1;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
int line_init(void){
|
|||
|
|
if(read_rank_flash(&ranks) == 1){
|
|||
|
|
// memcpy(scan_X_line, ranks.x_rank, sizeof(scan_X_line));
|
|||
|
|
// memcpy(scan_Y_line, ranks.y_rank, sizeof(scan_Y_line));
|
|||
|
|
return 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return 0; // <20><>ʼ<EFBFBD><CABC><EFBFBD>ɹ<EFBFBD>
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int save_config_ranks(uint8_t x[12],uint8_t y[12])
|
|||
|
|
{
|
|||
|
|
ranks.head = RANKS_HEAD;
|
|||
|
|
ranks.tail = RANKS_TAIL;
|
|||
|
|
memcpy(ranks.x_rank, x, sizeof(scan_X_line));
|
|||
|
|
memcpy(ranks.y_rank, y, sizeof(scan_Y_line));
|
|||
|
|
flash_write(RANKS_ADDRESS,(uint16_t *)&ranks, sizeof(rank_frame_struct)/sizeof(uint16_t));
|
|||
|
|
line_init();
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
void soft_sensor(adc_value_frame_struct *adc_raw_value)
|
|||
|
|
{
|
|||
|
|
for(uint8_t ax = 0; ax < AX_NUM; ax++){
|
|||
|
|
for(uint8_t ay = 0; ay < AY_NUM; ay++)
|
|||
|
|
{
|
|||
|
|
// adc_raw_value->sensor_soft_value[ay][ax] = adc_raw_value->sensor_voltage[scan_Y_line[ay]][scan_X_line[ax]];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|