- use build in data types

git-svn-id: http://moon:8086/svn/mips@35 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
2015-05-28 19:19:01 +00:00
parent 3263f9d79c
commit a655e1c5d9
54 changed files with 1551 additions and 1583 deletions
+28 -28
View File
@@ -10,15 +10,15 @@
#include "libsys.h"
#include "irq.h"
UINT32 buffer[16384];
uint32_t buffer[16384];
#define T_SAMPLE 5000
#define TIMEOUT 1000
typedef struct _bar_t
{
UINT32 T;
UINT32 black;
uint32_t T;
uint32_t black;
} bar_t;
enum
@@ -30,13 +30,13 @@ enum
typedef struct _sbar_cand_t
{
UINT32 T;
UINT32 is_primitive;
uint32_t T;
uint32_t is_primitive;
} bar_cand_t;
bar_t bars[1024];
void bsort(float *pData, UINT32 len)
void bsort(float *pData, uint32_t len)
{
float t;
int i, j;
@@ -57,14 +57,14 @@ void bsort(float *pData, UINT32 len)
typedef struct _smedian_t
{
UINT32 N;
UINT32 is_dirty;
uint32_t N;
uint32_t is_dirty;
float *pBuf, *pSorted;
UINT32 w;
uint32_t w;
float median;
} median_t;
void Median_init(median_t *pObj, UINT32 N, float init_val)
void Median_init(median_t *pObj, uint32_t N, float init_val)
{
int i;
pObj->pBuf = (float*)malloc(N*sizeof(float));
@@ -124,9 +124,9 @@ float Median_get(median_t *pObj)
}
// -------------------------------------------------------------
UINT32 detect_module(UINT32 T, UINT32 T0)
uint32_t detect_module(uint32_t T, uint32_t T0)
{
UINT32 m, best_M;
uint32_t m, best_M;
float err, kc, best_err;
best_err = 4.f;
@@ -149,16 +149,16 @@ UINT32 detect_module(UINT32 T, UINT32 T0)
void handler7(void)
{
UINT32 volatile *pTim_ctrl = (UINT32*)SYS_ITIM_CTRL;
UINT32 volatile *pTim_stat = (UINT32*)SYS_ITIM_STAT;
UINT32 volatile *pPS20_stat = (UINT32*)SYS_PS2_0_STAT;
UINT32 volatile *pPS21_stat = (UINT32*)SYS_PS2_1_STAT;
static UINT32 state, bar_count;
static UINT32 timeout_count, timeout_reload;
static UINT32 white, pin_last, skip, start;
static UINT32 module_cnt_w, module_cnt_b, Tmod0_w, Tmod0_b, M, T0;
uint32_t volatile *pTim_ctrl = (uint32_t*)SYS_ITIM_CTRL;
uint32_t volatile *pTim_stat = (uint32_t*)SYS_ITIM_STAT;
uint32_t volatile *pPS20_stat = (uint32_t*)SYS_PS2_0_STAT;
uint32_t volatile *pPS21_stat = (uint32_t*)SYS_PS2_1_STAT;
static uint32_t state, bar_count;
static uint32_t timeout_count, timeout_reload;
static uint32_t white, pin_last, skip, start;
static uint32_t module_cnt_w, module_cnt_b, Tmod0_w, Tmod0_b, M, T0;
float ratio, error, kc;
UINT32 i;
uint32_t i;
static median_t med_b, med_w;
static bar_cand_t bc_b, bc_w;
static median_t speed_b, speed_w;
@@ -274,7 +274,7 @@ void handler7(void)
// printf("M=%d, R=%2.2f, E=%+2.2f [%04d]", M, ratio, error, T0);
// if (M == 1)
Median_value_add(&med_b, (UINT32)(T0*kc));
Median_value_add(&med_b, (uint32_t)(T0*kc));
Median_value_add(&speed_b, (float)bars[i].T/(M*Tmod0_b));
printf("%06d %2.6f ", bars[i].T, Median_get(&speed_b));
@@ -303,7 +303,7 @@ void handler7(void)
// printf(" M=%d, R=%2.2f, E=%+2.2f [%04d]", M, ratio, error, T0);
// if (M == 1)
Median_value_add(&med_w, (UINT32)(T0*kc));
Median_value_add(&med_w, (uint32_t)(T0*kc));
Median_value_add(&speed_w, (float)bars[i].T/(M*Tmod0_w));
printf("%06d %2.6f ", bars[i].T, Median_get(&speed_w));
@@ -335,13 +335,13 @@ int main(void)
{
int i;
UINT32 volatile *pTim_ctrl = (UINT32*)SYS_ITIM_CTRL;
UINT32 volatile *pTim_stat = (UINT32*)SYS_ITIM_STAT;
UINT32 volatile *pTim0_cnt = (UINT32*)SYS_ITIM0_CNT;
UINT32 volatile *pTim0_cmp = (UINT32*)SYS_ITIM0_CMP;
uint32_t volatile *pTim_ctrl = (uint32_t*)SYS_ITIM_CTRL;
uint32_t volatile *pTim_stat = (uint32_t*)SYS_ITIM_STAT;
uint32_t volatile *pTim0_cnt = (uint32_t*)SYS_ITIM0_CNT;
uint32_t volatile *pTim0_cmp = (uint32_t*)SYS_ITIM0_CMP;
*pTim0_cnt = 0;
*pTim0_cmp = (UINT32)T_SAMPLE;
*pTim0_cmp = (uint32_t)T_SAMPLE;
*pTim_stat = 1;
*pTim_ctrl = 3;