⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uhal.c

📁 本程序为ST公司开发的源代码
💻 C
字号:
/************************************************** * * <filename> * * CVS ID:   $Id: uHAL.c,v 1.16 2007/08/20 16:30:32 longauer Exp $ * Author:   Leos Longauer [LL] - STM * Date:     $Date: 2007/08/20 16:30:32 $ * Revision: $Revision: 1.16 $ *  * Description: *  *   Hardware abstraction layer. * *************************************************** *  * COPYRIGHT (C) ST Microelectronics  2005 *            All Rights Reserved * *************************************************** * * STM CVS Log: * * $Log: uHAL.c,v $ * Revision 1.16  2007/08/20 16:30:32  longauer * more robust HIGH_Z setting (proper timers handling) * * Revision 1.15  2007/06/04 16:58:46  longauer * USBtask rearrangement in order to support more logical units; new file usb_pri.h added with USBtask private declarations; USB compilation switches added; constants renaming; * * Revision 1.14  2007/02/09 12:14:50  belardi * First integration of iPod pass-through * * Revision 1.13  2006/12/04 16:30:38  longauer * CheckEnumeration can not be executed during BSR is pending. * * Revision 1.12  2006/09/18 09:55:26  belardi * Corrected CVS keyword usage * * Revision 1.11  2006/09/18 09:26:31  belardi * Added Log CVS keyword into file header * * ***************************************************/#include "gendef.h" /* required by osal.h */#include "osal.h"   /* required for ISR installation macro */#if (HAVE_USB==1)#include "debug.h"#include <string.h>#ifndef _DYN_MALLOC#include <stdlib.h>#endif /*_DYN_MALLOC*/#include "gendef.h"#include "lld_eic.h"#include "accordoptimer.h"#include "dynmem.h"#include "uHAL.h"unsigned char bChar;unsigned int dTimerInterval = 0;/* defined in usb.c */extern void usb_isr_hdl(void);/* ---interrupt related function pointers--- */void (*pfServiceUsb)(unsigned int InterruptNumber);void (*pfServiceUsbTimer)(void);/* ------------------- FUNCTIONS ------------------- */void uHALr_RequestInterrupt (unsigned int IrqNo, void (*pfUsbIsr)(), unsigned char* IsrName){//	if (IrqNo == IRQ_USBIT)		pfServiceUsb = pfUsbIsr;}int uHALr_RequestTimer (void (*MGC_TimerExpired)(), unsigned char* timer_name){//	if (timer_name == "timer")		pfServiceUsbTimer = MGC_TimerExpired;				return 0; /* return index of the timer used by usb */}/* ---interrupt permission--- *//* It should enable interrupt in two steps.	1. on-board interrupt controller	2. interrupt mask on the procesor. */void uHALr_EnableInterrupt(unsigned int IrqNo){//	if (IrqNo == IRQ_USBIT)		OSAL_isr_install((OSAL_ISR_ID_t)IrqNo, 0x0f, (CALLBACK_fnct)usb_isr_hdl);}/* It should disable the interrupt on the interrupt controller and	does not affect masking by the procesor. */void uHALr_DisableInterrupt(unsigned int IrqNo){//	if (IrqNo == IRQ_USBIT)		EIC_DisableChannel(IrqNo);}/* It should remove high-level handler from the specified interrupt. */void uHALr_FreeInterrupt(unsigned int IrqNo){//	if (IrqNo == IRQ_USBIT)		EIC_DisableChannel(IrqNo);}/* ---timer related functions--- *//*int uHALr_SetTimerState(unsigned int iIndex, unsigned char bPeriodic){	return set_timer_state(iIndex, bPeriodic);}*//* It should set the interval, in [ms], for the specified timer. */int uHALr_SetTimerInterval(unsigned int iIndex, unsigned int dwInterval){	dTimerInterval = dwInterval;	return 0;}/*int uHALr_GetTimerState(unsigned int iTimerIndex){	if (iTimerIndex == 0) return T_FREE;	//for 1. timer	if (iTimerIndex == 1) return T_BUSY;	//for 2. timer	return T_NOT_EXISTS;	//for next timer}void uHALr_InstallTimer(int iIndex){	install_timer(iIndex);}*//* It should reload the interval and enables the specified timer. */void uHALr_EnableTimer(int iIndex){	start_timer(USB_TIMER, dTimerInterval);}void uHALir_DisableTimer(int iIndex){	/* timer can not be disabled */	stop_timer(USB_TIMER);}/*unsigned int uHALir_CountTimers(void){	return 2; // 2 timers available on the chip}*/unsigned int uHALir_GetTimerInterrupt(int iIndex){	return IRQ_TIMERIT;	/* we use only 1 timer */}//[LL] new one/*int uHALr_FreeTimer(unsigned int iIndex){	pfServiceUsbTimer = NULL;	return 0;}*/#if (MUSB_DIAG!=0)int uHALr_CharAvailable(void){//	return (int)(((bChar = scan_char()) != 0) ? 1 : 0);	return 0;}unsigned char uHALr_getchar(void){//	return bChar;	return 0x00;}void uHALr_putchar(unsigned char bData){//	print_char(bData);}int uHALr_printf(const unsigned char* pInput){	/* TBD */	DBG_PRINTF(pInput);//	return print_string(pString);	return 0;}#endif /*MUSB_DIAG*//*void HAL_SemaphoreSignal(void){	OSAL_wake_thread(OSAL_THREAD_USBTask);}*/void* uHALr_malloc(unsigned long dwLength){#ifdef _DYN_MALLOC	return DYN_malloc((unsigned short) dwLength);#else	return malloc((unsigned short) dwLength);#endif /*_DYN_MALLOC*/}void uHALr_free(void* pDestination){#ifdef _DYN_MALLOC	DYN_free(pDestination);#else	free(pDestination);#endif /*_DYN_MALLOC*/}void uHALr_memcpy(void* pDestination, void* pSource, unsigned short iSize){	memcpy(pDestination, pSource, iSize);}void uHALr_memset(void* pDestination, unsigned short iData, unsigned short iSize){	memset(pDestination, iData, iSize);}#else /*HAVE_USB*//* ------------------- FUNCTIONS ------------------- */void uHALr_RequestInterrupt (unsigned int IrqNo, void (*pfUsbIsr)(), unsigned char* IsrName) {}int uHALr_RequestTimer (void (*MGC_TimerExpired)(), unsigned char* timer_name) {return 0;}void uHALr_EnableInterrupt(unsigned int IrqNo) {}void uHALr_DisableInterrupt(unsigned int IrqNo) {}void uHALr_FreeInterrupt(unsigned int IrqNo) {}int uHALr_SetTimerInterval(unsigned int iIndex, unsigned int dwInterval) {return 0;}void uHALr_EnableTimer(int iIndex) {}void uHALir_DisableTimer(int iIndex) {}unsigned int uHALir_GetTimerInterrupt(int iIndex) {return 0;}//int uHALr_FreeTimer(unsigned int iIndex) {return 0;}	//[LL] new one#if (MUSB_DIAG!=0)int uHALr_CharAvailable(void) {return 0;}unsigned char uHALr_getchar(void) {return 0;}void uHALr_putchar(unsigned char bData) {}int uHALr_printf(const unsigned char* pInput) {}#endif /*MUSB_DIAG*/void* uHALr_malloc(unsigned long dwLength) {}void uHALr_free(void* pDestination) {}void uHALr_memcpy(void* pDestination, void* pSource, unsigned short iSize) {}void uHALr_memset(void* pDestination, unsigned short iData, unsigned short iSize) {}#endif /*HAVE_USB*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -