pwt.h
来自「OMAP1030 处理器的ARM 侧硬件测试代码 OMAP1030 是TI」· C头文件 代码 · 共 263 行
H
263 行
//------------------------------------------------------------------------------
// TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION
//
// Property of Texas Instruments -- For Unrestricted Internal Use Only
// Unauthorized reproduction and/or distribution is strictly prohibited. This
// product is protected under copyright law and trade secret law as an
// unpublished work. Created 1987, (C) Copyright 1997 Texas Instruments. All
// rights reserved.
//
//
// Filename : pwt.h
// Description :
// Generate modulated frequency signal for external buzzer
// between 349 Hz and 5275 Hz with 12 half tone frequencies
// per octave and programmable volume.
// Project : Samsom
// Author : Francois Reygagne freygagne@tif.ti.com
// Functions Provided:
// DISABLE_CLOCK = disable PWT_CLK
// ENABLE_CLOCK = enable PWT_CLK
// DIV_154_OFF = divider 1/154 is not used
// DIV_154_ON = divider 1/154 is used
// TONE_ONOFF = TONE is turn off
// TONE_ONOFF = TONE is on
//--------------------------------------------------------------------------
#ifndef __PWT_H
#define __PWT_H
#include "result.h"
#include "test.h"
#include "mapping.h"
/* PWT registers definition */
// PWT Frequency Control Register
//================================
#define PWT_FRC_OFFSET 0x0
#define PWT_FRC_REG REG8(MEM_PWT_ADDR+PWT_FRC_OFFSET)
#define PWT_FRC_RESET_VALUE 0x00
#define PWT_FRC_OCT_MASK 0x03
#define PWT_FRC_OCT_POS 0x0
#define PWT_FRC_OCT_NUMB 0x2
#define PWT_FRC_OCT_RES_VAL 0x0
#define PWT_FRC_FRQ_MASK 0x3C
#define PWT_FRC_FRQ_POS 0x2
#define PWT_FRC_FRQ_NUMB 0x4
#define PWT_FRC_FRQ_RES_VAL 0x0
#define PWT_e 0x0
#define PWT_dis 0x1
#define PWT_d 0x2
#define PWT_cis 0x3
#define PWT_c 0x4
#define PWT_h 0x5
#define PWT_ais 0x6
#define PWT_a 0x7
#define PWT_gis 0x8
#define PWT_g 0x9
#define PWT_fis 0xA
#define PWT_f 0xB
#define PWT_OCTAVE0 0x0
#define PWT_OCTAVE1 0x1
#define PWT_OCTAVE2 0x2
#define PWT_OCTAVE3 0x3
// PWT Volume Control Register
//=============================
#define PWT_VRC_OFFSET 0x1
#define PWT_VRC_REG REG8(MEM_PWT_ADDR+ALIGNOrNotOn32Bits_from8bits(PWT_VRC_OFFSET))
#define PWT_VRC_RESET_VALUE 0x00
#define PWT_ONOFF_MASK 0x1
#define PWT_ONOFF_POS 0x0
#define PWT_ONOFF_NUMB 0x1
#define PWT_ONOFF_RES_VAL 0x0
#define PWT_VOL_MASK 0x7E
#define PWT_VOL_POS 0x1
#define PWT_VOL_NUMB 0x0
#define PWT_VOL_RES_VAL 0x0
#define PWT_ON 0x1
#define PWT_OFF 0x0
#define PWT_QUIET 0x0
#define PWT_LOUD 0x3F
#define PWT_MEDIUM 0x1F
// PWT General Control Register
//==============================
#define PWT_GCR_OFFSET 0x2
#define PWT_GCR_REG REG8(MEM_PWT_ADDR+ALIGNOrNotOn32Bits_from8bits(PWT_GCR_OFFSET))
#define PWT_GCR_RES_VAL 0x00
#define PWT_CKEN_MASK 0x1
#define PWT_CKEN_POS 0x1
#define PWT_CKEN_NUMB 0x1
#define PWT_CKEN_RES_VAL 0x0
#define PWT_TESTIN_MASK 0x2
#define PWT_TESTIN_POS 0x1
#define PWT_TESTIN_NUMB 0x1
#define PWT_TESTIN_RES_VAL 0x0
#define PWT_CLK_ENABLE 0x0
#define PWT_CLK_DISABLE 0x1
#define PWT_TESTIN_ENABLE 0x0
#define PWT_TESTIN_DISABLE 0x1
/* Usefull constants */
// Internal registers constants
#define PWT_CLK_EN 0x01 // 1 => PWT_CLK is enabled
#define PWT_DIV154_BYP 0x02 // 1 => 1/154 divider bypass is enabled
#define PWT_TONE_ONOFF 0x01 // 0 => the TONE output is switched off
// Timer data
#define PWT_VTCXO 13 // VTCXO frequency in Mhz
#define PWT_PRESCALE_TIMER_VALUE TIMER_PRE_SCALE_7 // Pre-scale clock Timer Value
// External arrays
extern UWORD8 f[], fis[], g[], gis[], a[], ais[], h[], c[], cis[], d[], dis[], e[];
/* Macros definition */
//----------------------------------------------------------
// PWT_DISABLE_CLOCK : disable PWT_CLK
//-----------------------------------------------------------
#define PWT_DISABLE_CLOCK (PWT_GCR_REG &= ~PWT_CLK_EN )
//----------------------------------------------------------
// PWT_ENABLE_CLOCK : enable PWT_CLK
//-----------------------------------------------------------
#define PWT_ENABLE_CLOCK (PWT_GCR_REG |= PWT_CLK_EN )
//----------------------------------------------------------
// PWT_DIV_154_OFF : divider 1/154 is not used
//-----------------------------------------------------------
#define PWT_DIV_154_OFF (PWT_GCR_REG |= PWT_DIV154_BYP)
//----------------------------------------------------------
// PWT_DIV_154_ON : divider 1/154 is used
//-----------------------------------------------------------
#define PWT_DIV_154_ON (PWT_GCR_REG &= ~PWT_DIV154_BYP)
//----------------------------------------------------------
// PWT_TONE_OFF : TONE is turn off
//------------------------------------------------------------
#define PWT_TONE_OFF (PWT_VRC_REG &= ~PWT_TONE_ONOFF)
//----------------------------------------------------------
// PWT_TONE_ON : TONE is on
//------------------------------------------------------------
#define PWT_TONE_ON (PWT_VRC_REG |= PWT_TONE_ONOFF)
//------------------------------------------------------------
// Spy_Error_t : ERROR raised and written into spy results
//------------------------------------------------------------
typedef enum {
FRC_REG_RESET_ERROR = 0x60,
VRC_REG_RESET_ERROR = 0x61,
FRC_REG_READ_ERROR_1 = 0x62,
VRC_REG_READ_ERROR_1 = 0x63,
FRC_REG_READ_ERROR_2 = 0x64,
VRC_REG_READ_ERROR_2 = 0x65,
FRC_REG_READ_ERROR_3 = 0x66,
VRC_REG_READ_ERROR_3 = 0x67
} Spy_Error_t;
/*############################################################################
NAME : PWT_SET_OCTAVE
DESCRIPTION : Set the new octave
PARAMETERS : OCTAVE0..3 or a number between 0 and 3
RETURN VALUE: None
LIMITATIONS : None
############################################################################*/
#define PWT_SET_OCTAVE(octave) \
PWT_FRC_REG=(((octave)<<PWT_FRC_OCT_POS)| \
(PWT_FRC_REG&(~PWT_FRC_OCT_MASK)))
/*############################################################################
NAME : PWT_SET_FREQUENCY
DESCRIPTION : Set the new frequency
PARAMETERS : PWT_e ... dis .. g ... gis .....or a number between 0x0 and 0xB
RETURN VALUE: None
LIMITATIONS : None
############################################################################*/
#define PWT_SET_FREQUENCY(frequency) \
PWT_FRC_REG=(((frequency)<<PWT_FRC_FRQ_POS)|\
(PWT_FRC_REG&(~PWT_FRC_FRQ_MASK)))
/*############################################################################
NAME : PWT_SET_POWER
DESCRIPTION : Switch ON/OFF the PWT module
PARAMETERS : PWT_ON / PWT_OFF
RETURN VALUE: None
LIMITATIONS : None
############################################################################*/
#define PWT_SET_POWER(askOnOff) \
PWT_VRC_REG=(((askOnOff)<<PWT_ONOFF_POS)| \
(PWT_VRC_REG&(~PWT_ONOFF_MASK)))
/*############################################################################
NAME : PWT_SET_VOLUME
DESCRIPTION : Switch ON/OFF the PWT module
PARAMETERS : PWT_ON / PWT_OFF
RETURN VALUE: None
LIMITATIONS : None
############################################################################*/
#define PWT_SET_VOLUME(newVolume) \
PWT_VRC_REG=(((newVolume)<<PWT_VOL_POS)| \
(PWT_VRC_REG&(~PWT_ONOFF_MASK)))
/*############################################################################
NAME : PWT_SET_CLOCK
DESCRIPTION : Enable / disable clock
PARAMETERS : PWT_CGR_CLK_ENABLE / PWT_CGR_CLK_DISABLE
RETURN VALUE: None
LIMITATIONS : None
############################################################################*/
#define PWT_SET_CLOCK(clockState) \
PWT_GCR_REG=(((clockState)<<PWT_CKEN_POS)| \
(PWT_GCR_REG&(~PWT_CKEN_MASK)))
/*############################################################################
NAME : PWT_SET_TESTIN
DESCRIPTION : Enable / disable 1/154 divider
PARAMETERS : PWT_CGR_TESTIN_ENABLE / PWT_CGR_TESTIN_DISABLE
RETURN VALUE: None
LIMITATIONS : None
############################################################################*/
#define PWT_SET_TESTIN(testInState) \
PWT_GCR_REG=(((testInState)<<PWT_TESTIN_POS)| \
(PWT_GCR_REG&(~PWT_TESTIN_MASK)))
/* Prototypes */
void PWT_Wait(const UWORD16 value, UWORD8* const fiqCount);
void PWT_Set(const UWORD8 volume, const UWORD8 buz_freq, UWORD8* const fiqCount, const UWORD8 wait);
UWORD16 PWT_TestRegisters(void);
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?