- 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
+27 -27
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,7 +30,7 @@ enum
bar_t bars[1024];
void bsort(float *pData, UINT32 len)
void bsort(float *pData, uint32_t len)
{
float t;
int i, j;
@@ -51,14 +51,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));
@@ -118,9 +118,9 @@ float Median_get(median_t *pObj)
}
// -------------------------------------------------------------
UINT32 detect_module(UINT32 T, UINT32 *pBC)
uint32_t detect_module(uint32_t T, uint32_t *pBC)
{
UINT32 m, best_M;
uint32_t m, best_M;
float err, kc, best_err;
best_err = 4.f;
@@ -143,18 +143,18 @@ UINT32 detect_module(UINT32 T, UINT32 *pBC)
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, j;
uint32_t i, j;
static median_t med_b, med_w;
static UINT32 bc_b[4], bc_w[4];
static uint32_t bc_b[4], bc_w[4];
if (*pTim_stat & 1)
{
@@ -254,7 +254,7 @@ void handler7(void)
Median_value_add(&med_b, kc);
printf("M=%d, R=%2.2f, E=%+2.2f [%04d]", M, kc, error, bc_b[M-1]);
kc = Median_get(&med_b);
bc_b[M-1] = (UINT32)(kc*bc_b[M-1]);
bc_b[M-1] = (uint32_t)(kc*bc_b[M-1]);
}
// printf("%d", M);
@@ -269,7 +269,7 @@ void handler7(void)
Median_value_add(&med_w, kc);
printf(" M=%d, R=%2.2f, E=%+2.2f [%04d]", M, kc, error, bc_w[M-1]);
kc = Median_get(&med_w);
bc_w[M-1] = (UINT32)(kc*bc_w[M-1]);
bc_w[M-1] = (uint32_t)(kc*bc_w[M-1]);
}
// printf("%d", M);
@@ -299,13 +299,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;