- use build in data types
git-svn-id: http://moon:8086/svn/mips@35 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
@@ -6,9 +6,9 @@
|
||||
#include "gpio.h"
|
||||
#include "hpi.h"
|
||||
|
||||
static volatile UINT32 _g_int_active;
|
||||
static volatile UINT32 _g_mbx_return;
|
||||
static volatile UINT32 _g_mbx_in_flag;
|
||||
static volatile uint32_t _g_int_active;
|
||||
static volatile uint32_t _g_mbx_return;
|
||||
static volatile uint32_t _g_mbx_in_flag;
|
||||
|
||||
extern gpio_if_t _g_gpio;
|
||||
|
||||
@@ -48,9 +48,9 @@ static usb_t _g_usb[USB_MAX_NUM_PORTS];
|
||||
// ---------------------------------------------------------
|
||||
void cy67k3_isr(void)
|
||||
{
|
||||
INT32 i;
|
||||
UINT16 sie_msg, hpi_status;
|
||||
UINT32 port, siemsg_handled, int_handled;
|
||||
int32_t i;
|
||||
uint16_t sie_msg, hpi_status;
|
||||
uint32_t port, siemsg_handled, int_handled;
|
||||
_g_int_active = 1;
|
||||
hpi_status = cy67k3_read_HPI_STATUS();
|
||||
|
||||
@@ -318,69 +318,69 @@ void cy67k3_reset(void)
|
||||
|
||||
}
|
||||
|
||||
UINT16 cy67k3_read_HPI_DATA(void)
|
||||
uint16_t cy67k3_read_HPI_DATA(void)
|
||||
{
|
||||
volatile UINT32 *pHpi = (UINT32*)SYS_USB_DATA;
|
||||
volatile uint32_t *pHpi = (uint32_t*)SYS_USB_DATA;
|
||||
|
||||
return (UINT16)*pHpi;
|
||||
return (uint16_t)*pHpi;
|
||||
}
|
||||
|
||||
UINT16 cy67k3_read_HPI_MAILBOX(void)
|
||||
uint16_t cy67k3_read_HPI_MAILBOX(void)
|
||||
{
|
||||
volatile UINT32 *pHpi = (UINT32*)SYS_USB_MBX;
|
||||
volatile uint32_t *pHpi = (uint32_t*)SYS_USB_MBX;
|
||||
|
||||
return (UINT16)*pHpi;
|
||||
return (uint16_t)*pHpi;
|
||||
}
|
||||
|
||||
UINT16 cy67k3_read_HPI_ADDRESS(void)
|
||||
uint16_t cy67k3_read_HPI_ADDRESS(void)
|
||||
{
|
||||
volatile UINT32 *pHpi = (UINT32*)SYS_USB_ADDR;
|
||||
volatile uint32_t *pHpi = (uint32_t*)SYS_USB_ADDR;
|
||||
|
||||
return (UINT16)*pHpi;
|
||||
return (uint16_t)*pHpi;
|
||||
}
|
||||
|
||||
UINT16 cy67k3_read_HPI_STATUS(void)
|
||||
uint16_t cy67k3_read_HPI_STATUS(void)
|
||||
{
|
||||
volatile UINT32 *pHpi = (UINT32*)SYS_USB_STATUS;
|
||||
volatile uint32_t *pHpi = (uint32_t*)SYS_USB_STATUS;
|
||||
|
||||
return (UINT16)*pHpi;
|
||||
return (uint16_t)*pHpi;
|
||||
}
|
||||
|
||||
void cy67k3_write_HPI_DATA(UINT16 data)
|
||||
void cy67k3_write_HPI_DATA(uint16_t data)
|
||||
{
|
||||
volatile UINT32 *pHpi = (UINT32*)SYS_USB_DATA;
|
||||
volatile uint32_t *pHpi = (uint32_t*)SYS_USB_DATA;
|
||||
|
||||
*pHpi = (UINT32)data;
|
||||
*pHpi = (uint32_t)data;
|
||||
}
|
||||
|
||||
void cy67k3_write_HPI_MAILBOX(UINT16 data)
|
||||
void cy67k3_write_HPI_MAILBOX(uint16_t data)
|
||||
{
|
||||
volatile UINT32 *pHpi = (UINT32*)SYS_USB_MBX;
|
||||
volatile uint32_t *pHpi = (uint32_t*)SYS_USB_MBX;
|
||||
|
||||
*pHpi = (UINT32)data;
|
||||
*pHpi = (uint32_t)data;
|
||||
}
|
||||
|
||||
void cy67k3_write_HPI_ADDRESS(UINT16 data)
|
||||
void cy67k3_write_HPI_ADDRESS(uint16_t data)
|
||||
{
|
||||
volatile UINT32 *pHpi = (UINT32*)SYS_USB_ADDR;
|
||||
volatile uint32_t *pHpi = (uint32_t*)SYS_USB_ADDR;
|
||||
|
||||
*pHpi = (UINT32)data;
|
||||
*pHpi = (uint32_t)data;
|
||||
}
|
||||
|
||||
void cy67k3_write_HPI_STATUS(UINT16 data)
|
||||
void cy67k3_write_HPI_STATUS(uint16_t data)
|
||||
{
|
||||
volatile UINT32 *pHpi = (UINT32*)SYS_USB_STATUS;
|
||||
volatile uint32_t *pHpi = (uint32_t*)SYS_USB_STATUS;
|
||||
|
||||
*pHpi = (UINT32)data;
|
||||
*pHpi = (uint32_t)data;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// HPI API
|
||||
// ---------------------------------------------------------
|
||||
UINT32 hpi_init(void)
|
||||
uint32_t hpi_init(void)
|
||||
{
|
||||
int i;
|
||||
UINT16 reg;
|
||||
uint16_t reg;
|
||||
|
||||
// ToDo: Enable HPI interrupt
|
||||
_g_int_active = 0;
|
||||
@@ -424,16 +424,16 @@ UINT32 hpi_init(void)
|
||||
return HPI_NOERROR;
|
||||
}
|
||||
|
||||
void hpi_mbx_write(UINT16 msgcode)
|
||||
void hpi_mbx_write(uint16_t msgcode)
|
||||
{
|
||||
_g_mbx_in_flag = 0;
|
||||
cy67k3_write_HPI_MAILBOX(msgcode);
|
||||
}
|
||||
|
||||
UINT32 hpi_mbx_read(void)
|
||||
uint32_t hpi_mbx_read(void)
|
||||
{
|
||||
UINT32 err;
|
||||
UINT16 cy_return;
|
||||
uint32_t err;
|
||||
uint16_t cy_return;
|
||||
|
||||
if (_g_int_active)
|
||||
{
|
||||
@@ -464,7 +464,7 @@ UINT32 hpi_mbx_read(void)
|
||||
return err;
|
||||
}
|
||||
|
||||
UINT32 hpi_check_addr(UINT16 addr)
|
||||
uint32_t hpi_check_addr(uint16_t addr)
|
||||
{
|
||||
if ((addr >= 0x0000) && (addr < 0x4000))
|
||||
return 0;
|
||||
@@ -479,9 +479,9 @@ UINT32 hpi_check_addr(UINT16 addr)
|
||||
return HPI_ERR_INVPARAM;
|
||||
}
|
||||
|
||||
UINT32 hpi_read_reg(UINT16 addr)
|
||||
uint32_t hpi_read_reg(uint16_t addr)
|
||||
{
|
||||
UINT32 result;
|
||||
uint32_t result;
|
||||
|
||||
result = hpi_check_addr(addr);
|
||||
if (IS_ERROR(result))
|
||||
@@ -491,9 +491,9 @@ UINT32 hpi_read_reg(UINT16 addr)
|
||||
return cy67k3_read_HPI_DATA();
|
||||
}
|
||||
|
||||
UINT32 hpi_write_reg(UINT16 addr, UINT16 data)
|
||||
uint32_t hpi_write_reg(uint16_t addr, uint16_t data)
|
||||
{
|
||||
UINT32 result;
|
||||
uint32_t result;
|
||||
|
||||
result = hpi_check_addr(addr);
|
||||
if (IS_ERROR(result))
|
||||
@@ -503,7 +503,7 @@ UINT32 hpi_write_reg(UINT16 addr, UINT16 data)
|
||||
cy67k3_write_HPI_DATA(data);
|
||||
}
|
||||
|
||||
UINT32 hpi_write_ram(UINT16 addr, UINT16 *pData, UINT32 len)
|
||||
uint32_t hpi_write_ram(uint16_t addr, uint16_t *pData, uint32_t len)
|
||||
{
|
||||
int i, num_words;
|
||||
|
||||
@@ -525,7 +525,7 @@ UINT32 hpi_write_ram(UINT16 addr, UINT16 *pData, UINT32 len)
|
||||
return len;
|
||||
}
|
||||
|
||||
UINT32 hpi_read_ram(UINT16 addr, UINT16 *pData, UINT32 len)
|
||||
uint32_t hpi_read_ram(uint16_t addr, uint16_t *pData, uint32_t len)
|
||||
{
|
||||
int i, num_words;
|
||||
|
||||
@@ -547,14 +547,14 @@ UINT32 hpi_read_ram(UINT16 addr, UINT16 *pData, UINT32 len)
|
||||
return len;
|
||||
}
|
||||
|
||||
UINT32 hpi_comm_reset(void)
|
||||
uint32_t hpi_comm_reset(void)
|
||||
{
|
||||
hpi_mbx_write(COMM_RESET);
|
||||
|
||||
return hpi_mbx_read();
|
||||
}
|
||||
|
||||
UINT32 hpi_comm_jump2code(UINT16 addr)
|
||||
uint32_t hpi_comm_jump2code(uint16_t addr)
|
||||
{
|
||||
cy67k3_write_HPI_ADDRESS(addr);
|
||||
hpi_mbx_write(COMM_JUMP2CODE);
|
||||
@@ -562,7 +562,7 @@ UINT32 hpi_comm_jump2code(UINT16 addr)
|
||||
return hpi_mbx_read();
|
||||
}
|
||||
|
||||
UINT32 hpi_comm_callcode(UINT16 addr)
|
||||
uint32_t hpi_comm_callcode(uint16_t addr)
|
||||
{
|
||||
hpi_write_reg(COMM_CODE_ADDR, addr);
|
||||
|
||||
@@ -571,7 +571,7 @@ UINT32 hpi_comm_callcode(UINT16 addr)
|
||||
return hpi_mbx_read();
|
||||
}
|
||||
|
||||
UINT32 hpi_comm_write_ctrl_reg(UINT16 addr, UINT16 data, UINT16 logic)
|
||||
uint32_t hpi_comm_write_ctrl_reg(uint16_t addr, uint16_t data, uint16_t logic)
|
||||
{
|
||||
|
||||
hpi_write_reg(COMM_CTRL_REG_ADDR, addr);
|
||||
@@ -583,9 +583,9 @@ UINT32 hpi_comm_write_ctrl_reg(UINT16 addr, UINT16 data, UINT16 logic)
|
||||
return hpi_mbx_read();
|
||||
}
|
||||
|
||||
UINT32 hpi_comm_read_ctrl_reg(UINT16 addr)
|
||||
uint32_t hpi_comm_read_ctrl_reg(uint16_t addr)
|
||||
{
|
||||
UINT32 result;
|
||||
uint32_t result;
|
||||
|
||||
hpi_write_reg(COMM_CTRL_REG_ADDR, addr);
|
||||
|
||||
@@ -596,17 +596,17 @@ UINT32 hpi_comm_read_ctrl_reg(UINT16 addr)
|
||||
return result;
|
||||
|
||||
cy67k3_write_HPI_ADDRESS(COMM_CTRL_REG_DATA);
|
||||
return (UINT32)cy67k3_read_HPI_DATA();
|
||||
return (uint32_t)cy67k3_read_HPI_DATA();
|
||||
|
||||
}
|
||||
|
||||
UINT32 hpi_comm_write_xmem(UINT16 addr, UINT8 *pData, UINT16 len)
|
||||
uint32_t hpi_comm_write_xmem(uint16_t addr, uint8_t *pData, uint16_t len)
|
||||
{
|
||||
return HPI_ERR_NOTIMPL;
|
||||
|
||||
}
|
||||
|
||||
UINT32 hpi_comm_read_xmem(UINT16 addr, UINT8 *pData, UINT16 len)
|
||||
uint32_t hpi_comm_read_xmem(uint16_t addr, uint8_t *pData, uint16_t len)
|
||||
{
|
||||
return HPI_ERR_NOTIMPL;
|
||||
|
||||
@@ -614,15 +614,15 @@ UINT32 hpi_comm_read_xmem(UINT16 addr, UINT8 *pData, UINT16 len)
|
||||
|
||||
typedef struct _sreg_param_t
|
||||
{
|
||||
UINT32 id;
|
||||
UINT16 val;
|
||||
uint32_t id;
|
||||
uint16_t val;
|
||||
|
||||
} reg_param_t;
|
||||
|
||||
UINT32 hpi_comm_exec_int(UINT16 intnum, UINT32 nargs, ...)
|
||||
uint32_t hpi_comm_exec_int(uint16_t intnum, uint32_t nargs, ...)
|
||||
{
|
||||
int i;
|
||||
UINT32 result;
|
||||
uint32_t result;
|
||||
va_list args;
|
||||
reg_param_t reg_param[MAX_NUM_REGS];
|
||||
|
||||
@@ -636,14 +636,14 @@ UINT32 hpi_comm_exec_int(UINT16 intnum, UINT32 nargs, ...)
|
||||
|
||||
for (i=0; i < nargs; i++)
|
||||
{
|
||||
reg_param[i].id = va_arg(args, UINT32);
|
||||
reg_param[i].id = va_arg(args, uint32_t);
|
||||
if (reg_param[i].id > MAX_NUM_REGS)
|
||||
{
|
||||
fprintf(stderr, "hpi_comm_exec_int(): Invalid register R%d!\n", reg_param[i].id);
|
||||
return HPI_ERR_INVPARAM;
|
||||
}
|
||||
|
||||
reg_param[i].val = (UINT16)va_arg(args, UINT32);
|
||||
reg_param[i].val = (uint16_t)va_arg(args, uint32_t);
|
||||
}
|
||||
va_end(args);
|
||||
|
||||
@@ -660,12 +660,12 @@ UINT32 hpi_comm_exec_int(UINT16 intnum, UINT32 nargs, ...)
|
||||
if (IS_ERROR(result))
|
||||
return result;
|
||||
|
||||
return (UINT32)hpi_read_reg(COMM_R0);
|
||||
return (uint32_t)hpi_read_reg(COMM_R0);
|
||||
}
|
||||
|
||||
UINT32 usb_init(void)
|
||||
uint32_t usb_init(void)
|
||||
{
|
||||
INT32 i;
|
||||
int32_t i;
|
||||
|
||||
for (i=0; i < USB_MAX_NUM_PORTS; i++)
|
||||
{
|
||||
@@ -674,9 +674,9 @@ UINT32 usb_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT32 usb_callback_register(UINT32 port, UINT32 type, fp_t pFunc, void *pArg)
|
||||
uint32_t usb_callback_register(uint32_t port, uint32_t type, fp_t pFunc, void *pArg)
|
||||
{
|
||||
UINT32 result;
|
||||
uint32_t result;
|
||||
if (port >= USB_MAX_NUM_PORTS)
|
||||
return -1;
|
||||
|
||||
@@ -761,7 +761,7 @@ UINT32 usb_callback_register(UINT32 port, UINT32 type, fp_t pFunc, void *pArg)
|
||||
return result;
|
||||
}
|
||||
|
||||
UINT32 usb_irp_register(usb_irp_t *pIRP, UINT32 port, UINT32 ept, UINT32 size, UINT32 is_out)
|
||||
uint32_t usb_irp_register(usb_irp_t *pIRP, uint32_t port, uint32_t ept, uint32_t size, uint32_t is_out)
|
||||
{
|
||||
|
||||
if (!pIRP)
|
||||
@@ -792,9 +792,9 @@ UINT32 usb_irp_register(usb_irp_t *pIRP, UINT32 port, UINT32 ept, UINT32 size, U
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT32 usb_irp_enqueue(usb_irp_t *pIRP)
|
||||
uint32_t usb_irp_enqueue(usb_irp_t *pIRP)
|
||||
{
|
||||
UINT32 result;
|
||||
uint32_t result;
|
||||
|
||||
if (!pIRP)
|
||||
{
|
||||
@@ -806,7 +806,7 @@ UINT32 usb_irp_enqueue(usb_irp_t *pIRP)
|
||||
|
||||
if (pIRP->is_out)
|
||||
{
|
||||
hpi_write_ram(pIRP->cy_irp_addr, (UINT16*)&pIRP->cy_req, sizeof(cy_req_t));
|
||||
hpi_write_ram(pIRP->cy_irp_addr, (uint16_t*)&pIRP->cy_req, sizeof(cy_req_t));
|
||||
if (pIRP->port == 0)
|
||||
result = hpi_comm_exec_int(SUSB1_RECEIVE_INT, 2, R1, pIRP->ept, R8, pIRP->cy_irp_addr);
|
||||
|
||||
@@ -816,7 +816,7 @@ UINT32 usb_irp_enqueue(usb_irp_t *pIRP)
|
||||
if (pIRP->is_in)
|
||||
{
|
||||
pIRP->tx_in_progress = 1;
|
||||
hpi_write_ram(pIRP->cy_irp_addr, (UINT16*)&pIRP->cy_req, sizeof(cy_req_t));
|
||||
hpi_write_ram(pIRP->cy_irp_addr, (uint16_t*)&pIRP->cy_req, sizeof(cy_req_t));
|
||||
if (pIRP->port == 0)
|
||||
result = hpi_comm_exec_int(SUSB1_SEND_INT, 2, R1, pIRP->ept, R8, pIRP->cy_irp_addr);
|
||||
|
||||
@@ -831,15 +831,15 @@ UINT32 usb_irp_enqueue(usb_irp_t *pIRP)
|
||||
|
||||
}
|
||||
|
||||
UINT32 fifo_alloc(fifo_t *pObj, UINT32 size)
|
||||
uint32_t fifo_alloc(fifo_t *pObj, uint32_t size)
|
||||
{
|
||||
pObj->pBuf = (UINT8*)malloc(size);
|
||||
pObj->pBuf = (uint8_t*)malloc(size);
|
||||
if (!pObj->pBuf)
|
||||
{
|
||||
// printf ("fifo_alloc(): Error allocating memory!\n");
|
||||
return -1;
|
||||
}
|
||||
// printf ("fifo_alloc(): pBuf at %8.8X\n", (UINT32)pObj->pBuf);
|
||||
// printf ("fifo_alloc(): pBuf at %8.8X\n", (uint32_t)pObj->pBuf);
|
||||
pObj->size = size;
|
||||
pObj->pPtr_wr = pObj->pBuf;
|
||||
pObj->pPtr_rd = pObj->pBuf;
|
||||
@@ -847,7 +847,7 @@ UINT32 fifo_alloc(fifo_t *pObj, UINT32 size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT32 fifo_free(fifo_t *pObj)
|
||||
uint32_t fifo_free(fifo_t *pObj)
|
||||
{
|
||||
if (pObj->pBuf)
|
||||
free(pObj->pBuf);
|
||||
@@ -855,7 +855,7 @@ UINT32 fifo_free(fifo_t *pObj)
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT32 fifo_flush(fifo_t *pObj)
|
||||
uint32_t fifo_flush(fifo_t *pObj)
|
||||
{
|
||||
pObj->pPtr_wr = pObj->pBuf;
|
||||
pObj->pPtr_rd = pObj->pBuf;
|
||||
@@ -863,14 +863,14 @@ UINT32 fifo_flush(fifo_t *pObj)
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT32 fifo_is_empty(fifo_t *pObj)
|
||||
uint32_t fifo_is_empty(fifo_t *pObj)
|
||||
{
|
||||
return (pObj->pPtr_wr == pObj->pPtr_rd);
|
||||
}
|
||||
|
||||
UINT32 fifo_is_full(fifo_t *pObj)
|
||||
uint32_t fifo_is_full(fifo_t *pObj)
|
||||
{
|
||||
UINT8 *pNext, *pEnd;
|
||||
uint8_t *pNext, *pEnd;
|
||||
|
||||
pEnd = pObj->pBuf + pObj->size;
|
||||
pNext = pObj->pPtr_wr + 1;
|
||||
@@ -880,11 +880,11 @@ UINT32 fifo_is_full(fifo_t *pObj)
|
||||
return (pNext == pObj->pPtr_rd);
|
||||
}
|
||||
|
||||
UINT32 fifo_read(fifo_t *pObj, UINT8 *pData, UINT32 size, UINT32 timeout, UINT32 do_block)
|
||||
uint32_t fifo_read(fifo_t *pObj, uint8_t *pData, uint32_t size, uint32_t timeout, uint32_t do_block)
|
||||
{
|
||||
UINT32 i;
|
||||
UINT32 wait_4ever, timeout_cnt, cnt;
|
||||
UINT8 *pEnd;
|
||||
uint32_t i;
|
||||
uint32_t wait_4ever, timeout_cnt, cnt;
|
||||
uint8_t *pEnd;
|
||||
|
||||
pEnd = pObj->pBuf + pObj->size;
|
||||
wait_4ever = (timeout == 0);
|
||||
@@ -927,10 +927,10 @@ UINT32 fifo_read(fifo_t *pObj, UINT8 *pData, UINT32 size, UINT32 timeout, UINT32
|
||||
return cnt;
|
||||
}
|
||||
|
||||
UINT32 fifo_write(fifo_t *pObj, UINT8 *pData, UINT32 size, UINT32 timeout, UINT32 do_block)
|
||||
uint32_t fifo_write(fifo_t *pObj, uint8_t *pData, uint32_t size, uint32_t timeout, uint32_t do_block)
|
||||
{
|
||||
UINT32 wait_4ever, timeout_cnt, cnt;
|
||||
UINT8 *pEnd;
|
||||
uint32_t wait_4ever, timeout_cnt, cnt;
|
||||
uint8_t *pEnd;
|
||||
|
||||
pEnd = pObj->pBuf + pObj->size;
|
||||
wait_4ever = (timeout == 0);
|
||||
|
||||
Reference in New Issue
Block a user