/Modules/Clock/CLKGEN01B/SW/DG8SAQ synthesiser_Emulator/HardwareProfile - PICDEM FSUSB.bak |
---|
0,0 → 1,210 |
/******************************************************************** |
FileName: HardwareProfile - PICDEM FSUSB.h |
Dependencies: See INCLUDES section |
Processor: PIC18 USB Microcontrollers |
Hardware: PICDEM FSUSB |
Compiler: Microchip C18 |
Company: Microchip Technology, Inc. |
Software License Agreement: |
The software supplied herewith by Microchip Technology Incorporated |
(the Company) for its PIC® Microcontroller is intended and |
supplied to you, the Companys customer, for use solely and |
exclusively on Microchip PIC Microcontroller products. The |
software is owned by the Company and/or its supplier, and is |
protected under applicable copyright laws. All rights are reserved. |
Any use in violation of the foregoing restrictions may subject the |
user to criminal sanctions under applicable laws, as well as to |
civil liability for the breach of the terms and conditions of this |
license. |
THIS SOFTWARE IS PROVIDED IN AN AS IS CONDITION. NO WARRANTIES, |
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED |
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, |
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR |
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. |
******************************************************************** |
File Description: |
Change History: |
Rev Date Description |
1.0 11/19/2004 Initial release |
2.1 02/26/2007 Updated for simplicity and to use common |
coding style |
2.3 09/15/2008 Broke out each hardware platform into its own |
"HardwareProfile - xxx.h" file |
********************************************************************/ |
#ifndef HARDWARE_PROFILE_PICDEM_FSUSB_H |
#define HARDWARE_PROFILE_PICDEM_FSUSB_H |
/*******************************************************************/ |
/******** USB stack hardware selection options *********************/ |
/*******************************************************************/ |
//This section is the set of definitions required by the MCHPFSUSB |
// framework. These definitions tell the firmware what mode it is |
// running in, and where it can find the results to some information |
// that the stack needs. |
//These definitions are required by every application developed with |
// this revision of the MCHPFSUSB framework. Please review each |
// option carefully and determine which options are desired/required |
// for your application. |
//The PICDEM FS USB Demo Board platform supports the USE_SELF_POWER_SENSE_IO |
//and USE_USB_BUS_SENSE_IO features. Uncomment the below line(s) if |
//it is desireable to use one or both of the features. |
//#define USE_SELF_POWER_SENSE_IO |
#define tris_self_power TRISAbits.TRISA2 // Input |
#if defined(USE_SELF_POWER_SENSE_IO) |
#define self_power PORTAbits.RA2 |
#else |
#define self_power 1 |
#endif |
//#define USE_USB_BUS_SENSE_IO |
#define tris_usb_bus_sense TRISAbits.TRISA1 // Input |
#if defined(USE_USB_BUS_SENSE_IO) |
#define USB_BUS_SENSE PORTAbits.RA1 |
#else |
#define USB_BUS_SENSE 1 |
#endif |
//Uncomment the following line to make the output HEX of this |
// project work with the MCHPUSB Bootloader |
//#define PROGRAMMABLE_WITH_USB_MCHPUSB_BOOTLOADER |
//Uncomment the following line to make the output HEX of this |
// project work with the HID Bootloader |
#define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER |
/*******************************************************************/ |
/******** MDD File System selection options ************************/ |
/*******************************************************************/ |
#define USE_PIC18 |
#define ERASE_BLOCK_SIZE 64 |
#define WRITE_BLOCK_SIZE 32 |
/*******************************************************************/ |
/*******************************************************************/ |
/*******************************************************************/ |
/******** Application specific definitions *************************/ |
/*******************************************************************/ |
/*******************************************************************/ |
/*******************************************************************/ |
/** Board definition ***********************************************/ |
//These defintions will tell the main() function which board is |
// currently selected. This will allow the application to add |
// the correct configuration bits as wells use the correct |
// initialization functions for the board. These defitions are only |
// required in the stack provided demos. They are not required in |
// final application design. |
#define DEMO_BOARD PICDEM_FS_USB |
#define PICDEM_FS_USB |
#define CLOCK_FREQ 48000000 |
/** LED ************************************************************/ |
#define mInitAllLEDs() LATD &= 0xF0; TRISD &= 0xF0; |
#define mLED_1 LATDbits.LATD0 |
#define mLED_2 LATDbits.LATD1 |
#define mLED_3 LATDbits.LATD2 |
#define mLED_4 LATDbits.LATD3 |
#define mGetLED_1() mLED_1 |
#define mGetLED_2() mLED_2 |
#define mGetLED_3() mLED_3 |
#define mGetLED_4() mLED_4 |
#define mLED_1_On() mLED_1 = 1; |
#define mLED_2_On() mLED_2 = 1; |
#define mLED_3_On() mLED_3 = 1; |
#define mLED_4_On() mLED_4 = 1; |
#define mLED_1_Off() mLED_1 = 0; |
#define mLED_2_Off() mLED_2 = 0; |
#define mLED_3_Off() mLED_3 = 0; |
#define mLED_4_Off() mLED_4 = 0; |
#define mLED_1_Toggle() mLED_1 = !mLED_1; |
#define mLED_2_Toggle() mLED_2 = !mLED_2; |
#define mLED_3_Toggle() mLED_3 = !mLED_3; |
#define mLED_4_Toggle() mLED_4 = !mLED_4; |
/** SWITCH *********************************************************/ |
#define mInitAllSwitches() TRISBbits.TRISB4=1;TRISBbits.TRISB5=1; |
#define mInitSwitch2() TRISBbits.TRISB4=1; |
#define mInitSwitch3() TRISBbits.TRISB5=1; |
#define sw2 PORTBbits.RB4 |
#define sw3 PORTBbits.RB5 |
/** POT ************************************************************/ |
#define mInitPOT() {TRISAbits.TRISA0=1;ADCON0=0x01;ADCON2=0x3C;ADCON2bits.ADFM = 1;} |
/** SPI : Chip Select Lines ****************************************/ |
#define tris_cs_temp_sensor TRISBbits.TRISB2 // Output |
#define cs_temp_sensor LATBbits.LATB2 |
/** USB external transceiver interface (optional) ******************/ |
#define tris_usb_vpo TRISBbits.TRISB3 // Output |
#define tris_usb_vmo TRISBbits.TRISB2 // Output |
#define tris_usb_rcv TRISAbits.TRISA4 // Input |
#define tris_usb_vp TRISCbits.TRISC5 // Input |
#define tris_usb_vm TRISCbits.TRISC4 // Input |
#define tris_usb_oe TRISCbits.TRISC1 // Output |
#define tris_usb_suspnd TRISAbits.TRISA3 // Output |
/** TRIS ***********************************************************/ |
#define INPUT_PIN 1 |
#define OUTPUT_PIN 0 |
#if defined(YAS) |
#define RXTX LATBbits.LATB5 |
#else |
#define RXTX LATAbits.LATA2 |
#endif |
#define BPF_S0 LATAbits.LATA0 |
#define BPF_S1 LATAbits.LATA1 |
#if defined(YAS) |
#define BPF_S2 LATAbits.LATA2 |
#endif |
#define BPF_S0_STATE PORTAbits.RA0 |
#define BPF_S1_STATE PORTAbits.RA1 |
#if defined(YAS) |
#define BPF_S2_STATE PORTAbits.RA2 |
#endif |
#define PADDLE_DIT PORTBbits.RB6 |
#define PADDLE_DAH PORTBbits.RB7 |
#define LPF_0 LATAbits.LATA3 |
#define LPF_1 LATAbits.LATA4 |
#define LPF_2 LATAbits.LATA5 |
#if defined(YAS) |
#else |
#define LPF_3 LATBbits.LATB2 |
#define LPF_4 LATBbits.LATB3 |
#define LPF_5 LATBbits.LATB4 |
#define LPF_6 LATBbits.LATB5 |
#endif |
/** S W I T C H *****************************************************/ |
#define mInitSwitch() TRISCbits.TRISC2 = 1; |
#define UserSW PORTCbits.RC2 |
#define mLED_Both_Off() {mLED_1_Off(); mLED_2_Off();} |
#define mLED_Both_On() {mLED_1_On(); mLED_2_On();} |
#define mLED_Only_1_On() {mLED_1_On(); mLED_2_Off();} |
#define mLED_Only_2_On() {mLED_1_Off(); mLED_2_On();} |
#endif //HARDWARE_PROFILE_PICDEM_FSUSB_H |
/Modules/Clock/CLKGEN01B/SW/DG8SAQ synthesiser_Emulator/user.bak |
---|
0,0 → 1,197 |
/********************************************************************* |
* |
* Microchip USB C18 Firmware Version 1.2 |
* |
********************************************************************* |
* FileName: user.h |
* Dependencies: See INCLUDES section below |
* Processor: PIC18 |
* Compiler: C18 3.11+ |
* Company: Microchip Technology, Inc. |
* |
* Software License Agreement |
* |
* The software supplied herewith by Microchip Technology Incorporated |
* (the Company) for its PICmicro® Microcontroller is intended and |
* supplied to you, the Companys customer, for use solely and |
* exclusively on Microchip PICmicro Microcontroller products. The |
* software is owned by the Company and/or its supplier, and is |
* protected under applicable copyright laws. All rights are reserved. |
* Any use in violation of the foregoing restrictions may subject the |
* user to criminal sanctions under applicable laws, as well as to |
* civil liability for the breach of the terms and conditions of this |
* license. |
* |
* THIS SOFTWARE IS PROVIDED IN AN AS IS CONDITION. NO WARRANTIES, |
* WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED |
* TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
* PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, |
* IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR |
* CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. |
* |
* Author Date Comment |
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
* Rawin Rojvanit 11/19/04 Original. |
* Rawin Rojvanit 05/14/07 Minor updates. |
********************************************************************/ |
#ifndef PICDEM_FS_DEMO_H |
#define PICDEM_FS_DEMO_H |
/** I N C L U D E S **********************************************************/ |
/** D E F I N I T I O N S ****************************************************/ |
// For custom LPF switchover points |
#define ALEX |
//#define K5OOR |
//#define MARC |
// YAS is defined in the HardwareProfile - UBW.h, if needed |
#if defined(YAS) |
#define NUM_BPF 8 |
#else |
#define NUM_BPF 4 |
#endif |
#define INIT_SI570_ON_STARTUP |
#define VERSION_MAJOR 16 |
#define VERSION_MINOR 04 |
#define DEFAULT_I2C_ADDRESS 0x55 |
#define PCF8574 0x39 // A2 A1 A0 -> 0 0 1 |
#define F_CAL_DONE 0 // EEPROM position of F_CAL_DONE flag. 4 bytes follow. |
#define F_CAL_DONE_VALUE 0x55 |
#define DEFAULT_FCRYST 114.285 |
//#if defined(UBW) |
#define F_INIT_FREQ 5 // 4 bytes follow |
//#elif defined(UBW32) |
//#define F_INIT_FREQ 2 // fcryst 4 bytes all stored in one 32 bit slot |
#endif |
#define F_INIT_FREQ_VALUE 0x55 |
#define DEFAULT_INIT_FREQ 56.32 |
#if defined(UBW) |
#define F_SMOOTH 10 // 2 bytes follow |
#elif defined(UBW32) |
#define F_SMOOTH 4 // 1 slot follow |
#endif |
#define F_SMOOTH_VALUE 0x55 |
#define DEFAULT_SMOOTH 3500 // ppm |
#define F_SUB_MUL_VALUE 0x55 |
#define DEFAULT_SUB 0.0 |
#define DEFAULT_MUL 1.0 |
#if defined(UBW) |
#define F_SUB_MUL 13 // 8 bytes follow |
#elif defined(UBW32) |
#define F_SUB_MUL 6 // 2 slots follow |
#endif |
#if defined(UBW) |
#define F_CROSS_OVER 22 // 32 bytes follow |
#elif defined(UBW32) |
#define F_CROSS_OVER 9 // 16 words stored in 16 (unsigned int) slots |
#endif |
#define F_CROSS_OVER_VALUE 0x55 |
#if defined(UBW) |
#define F_BLINK_LED 55 |
#elif defined(UBW32) |
#define F_BLINK_LED 26 |
#endif |
/** S T R U C T U R E S ******************************************************/ |
extern BYTE i2c_adr; |
extern BYTE command; |
extern BYTE replybuf[8]; |
extern WORD wCount; |
#define COMMAND_BUFFER_SIZE 16 |
#define DATA_PACKET_SIZE 6 |
typedef struct COMMAND_BUFFER |
{ |
BYTE command; |
WORD wCount; |
BYTE data[DATA_PACKET_SIZE]; |
} COMMAND_BUFFER_t; |
extern COMMAND_BUFFER_t command_buffer[COMMAND_BUFFER_SIZE]; |
extern BYTE current_command_in, current_command_out; |
extern BYTE command_count; |
extern double set_frequency; |
extern unsigned char tempBuf[8]; |
typedef union _avr_freq |
{ |
unsigned long qw; |
unsigned char bytes[4]; |
} avr_freq_t; |
extern avr_freq_t avr_freq, fcryst_freq; //frequency [MHz]*2^21 |
// fcryst freq [MHz]*2^24 |
extern avr_freq_t f_mul; // mul for set freq in 11.21 format |
typedef union _offset |
{ |
long qw; // signed offset in 11.21 format |
unsigned char bytes[4]; |
} offset_t; |
extern offset_t f_sub; |
extern unsigned char registers[6]; |
extern BYTE abpf_flag; |
extern double Smooth_double; |
extern double fcryst_double; |
extern WORD_VAL FilterCrossOver[8]; // 11.5 bit value Mhz |
extern float FilterSwitchOver[7]; |
extern WORD_VAL LPFCrossOver[8]; |
extern float LPFSwitchOver[7]; |
/** P U B L I C P R O T O T Y P E S *****************************************/ |
void UserInit(void); |
void ProcessIO(void); |
void Set_Freq_Handler(void); |
void Set_Register_Handler(void); |
void Set_Cal_Handler(void); |
void Set_Init_Freq_Handler(void); |
void Set_Smooth_Handler(void); |
void Set_Sub_Mul_Handler(void); |
void Reset_Si570(void); |
void Freeze (void); |
void Unfreeze (void); |
void Prep_rd (unsigned short); |
void WriteBk (void); |
void NewF (void); |
void SetNewFreq(void); |
void ReadRegs(void); |
void ReadStartUpConfiguration(void); |
void RunFreqProg(double); |
void SetFrequency(double); |
void Set_BPF(float); |
void Set_LPF(float); |
float Cross2Switch(WORD_VAL); |
WORD_VAL Switch2Cross(float); |
double Freq_From_Register(double); |
void Read_Command_Into_Buffer(void); |
void USBCheckUserRequest(void); |
void USBCheckUBWRequest(void); |
#endif //PICDEM_FS_DEMO_H |
/Modules/Clock/CLKGEN01A/SW/DG8SAQ synthesiser_Emulator/HardwareProfile - PICDEM FSUSB.bak |
---|
0,0 → 1,210 |
/******************************************************************** |
FileName: HardwareProfile - PICDEM FSUSB.h |
Dependencies: See INCLUDES section |
Processor: PIC18 USB Microcontrollers |
Hardware: PICDEM FSUSB |
Compiler: Microchip C18 |
Company: Microchip Technology, Inc. |
Software License Agreement: |
The software supplied herewith by Microchip Technology Incorporated |
(the Company) for its PIC® Microcontroller is intended and |
supplied to you, the Companys customer, for use solely and |
exclusively on Microchip PIC Microcontroller products. The |
software is owned by the Company and/or its supplier, and is |
protected under applicable copyright laws. All rights are reserved. |
Any use in violation of the foregoing restrictions may subject the |
user to criminal sanctions under applicable laws, as well as to |
civil liability for the breach of the terms and conditions of this |
license. |
THIS SOFTWARE IS PROVIDED IN AN AS IS CONDITION. NO WARRANTIES, |
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED |
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, |
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR |
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. |
******************************************************************** |
File Description: |
Change History: |
Rev Date Description |
1.0 11/19/2004 Initial release |
2.1 02/26/2007 Updated for simplicity and to use common |
coding style |
2.3 09/15/2008 Broke out each hardware platform into its own |
"HardwareProfile - xxx.h" file |
********************************************************************/ |
#ifndef HARDWARE_PROFILE_PICDEM_FSUSB_H |
#define HARDWARE_PROFILE_PICDEM_FSUSB_H |
/*******************************************************************/ |
/******** USB stack hardware selection options *********************/ |
/*******************************************************************/ |
//This section is the set of definitions required by the MCHPFSUSB |
// framework. These definitions tell the firmware what mode it is |
// running in, and where it can find the results to some information |
// that the stack needs. |
//These definitions are required by every application developed with |
// this revision of the MCHPFSUSB framework. Please review each |
// option carefully and determine which options are desired/required |
// for your application. |
//The PICDEM FS USB Demo Board platform supports the USE_SELF_POWER_SENSE_IO |
//and USE_USB_BUS_SENSE_IO features. Uncomment the below line(s) if |
//it is desireable to use one or both of the features. |
//#define USE_SELF_POWER_SENSE_IO |
#define tris_self_power TRISAbits.TRISA2 // Input |
#if defined(USE_SELF_POWER_SENSE_IO) |
#define self_power PORTAbits.RA2 |
#else |
#define self_power 1 |
#endif |
//#define USE_USB_BUS_SENSE_IO |
#define tris_usb_bus_sense TRISAbits.TRISA1 // Input |
#if defined(USE_USB_BUS_SENSE_IO) |
#define USB_BUS_SENSE PORTAbits.RA1 |
#else |
#define USB_BUS_SENSE 1 |
#endif |
//Uncomment the following line to make the output HEX of this |
// project work with the MCHPUSB Bootloader |
//#define PROGRAMMABLE_WITH_USB_MCHPUSB_BOOTLOADER |
//Uncomment the following line to make the output HEX of this |
// project work with the HID Bootloader |
#define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER |
/*******************************************************************/ |
/******** MDD File System selection options ************************/ |
/*******************************************************************/ |
#define USE_PIC18 |
#define ERASE_BLOCK_SIZE 64 |
#define WRITE_BLOCK_SIZE 32 |
/*******************************************************************/ |
/*******************************************************************/ |
/*******************************************************************/ |
/******** Application specific definitions *************************/ |
/*******************************************************************/ |
/*******************************************************************/ |
/*******************************************************************/ |
/** Board definition ***********************************************/ |
//These defintions will tell the main() function which board is |
// currently selected. This will allow the application to add |
// the correct configuration bits as wells use the correct |
// initialization functions for the board. These defitions are only |
// required in the stack provided demos. They are not required in |
// final application design. |
#define DEMO_BOARD PICDEM_FS_USB |
#define PICDEM_FS_USB |
#define CLOCK_FREQ 48000000 |
/** LED ************************************************************/ |
#define mInitAllLEDs() LATD &= 0xF0; TRISD &= 0xF0; |
#define mLED_1 LATDbits.LATD0 |
#define mLED_2 LATDbits.LATD1 |
#define mLED_3 LATDbits.LATD2 |
#define mLED_4 LATDbits.LATD3 |
#define mGetLED_1() mLED_1 |
#define mGetLED_2() mLED_2 |
#define mGetLED_3() mLED_3 |
#define mGetLED_4() mLED_4 |
#define mLED_1_On() mLED_1 = 1; |
#define mLED_2_On() mLED_2 = 1; |
#define mLED_3_On() mLED_3 = 1; |
#define mLED_4_On() mLED_4 = 1; |
#define mLED_1_Off() mLED_1 = 0; |
#define mLED_2_Off() mLED_2 = 0; |
#define mLED_3_Off() mLED_3 = 0; |
#define mLED_4_Off() mLED_4 = 0; |
#define mLED_1_Toggle() mLED_1 = !mLED_1; |
#define mLED_2_Toggle() mLED_2 = !mLED_2; |
#define mLED_3_Toggle() mLED_3 = !mLED_3; |
#define mLED_4_Toggle() mLED_4 = !mLED_4; |
/** SWITCH *********************************************************/ |
#define mInitAllSwitches() TRISBbits.TRISB4=1;TRISBbits.TRISB5=1; |
#define mInitSwitch2() TRISBbits.TRISB4=1; |
#define mInitSwitch3() TRISBbits.TRISB5=1; |
#define sw2 PORTBbits.RB4 |
#define sw3 PORTBbits.RB5 |
/** POT ************************************************************/ |
#define mInitPOT() {TRISAbits.TRISA0=1;ADCON0=0x01;ADCON2=0x3C;ADCON2bits.ADFM = 1;} |
/** SPI : Chip Select Lines ****************************************/ |
#define tris_cs_temp_sensor TRISBbits.TRISB2 // Output |
#define cs_temp_sensor LATBbits.LATB2 |
/** USB external transceiver interface (optional) ******************/ |
#define tris_usb_vpo TRISBbits.TRISB3 // Output |
#define tris_usb_vmo TRISBbits.TRISB2 // Output |
#define tris_usb_rcv TRISAbits.TRISA4 // Input |
#define tris_usb_vp TRISCbits.TRISC5 // Input |
#define tris_usb_vm TRISCbits.TRISC4 // Input |
#define tris_usb_oe TRISCbits.TRISC1 // Output |
#define tris_usb_suspnd TRISAbits.TRISA3 // Output |
/** TRIS ***********************************************************/ |
#define INPUT_PIN 1 |
#define OUTPUT_PIN 0 |
#if defined(YAS) |
#define RXTX LATBbits.LATB5 |
#else |
#define RXTX LATAbits.LATA2 |
#endif |
#define BPF_S0 LATAbits.LATA0 |
#define BPF_S1 LATAbits.LATA1 |
#if defined(YAS) |
#define BPF_S2 LATAbits.LATA2 |
#endif |
#define BPF_S0_STATE PORTAbits.RA0 |
#define BPF_S1_STATE PORTAbits.RA1 |
#if defined(YAS) |
#define BPF_S2_STATE PORTAbits.RA2 |
#endif |
#define PADDLE_DIT PORTBbits.RB6 |
#define PADDLE_DAH PORTBbits.RB7 |
#define LPF_0 LATAbits.LATA3 |
#define LPF_1 LATAbits.LATA4 |
#define LPF_2 LATAbits.LATA5 |
#if defined(YAS) |
#else |
#define LPF_3 LATBbits.LATB2 |
#define LPF_4 LATBbits.LATB3 |
#define LPF_5 LATBbits.LATB4 |
#define LPF_6 LATBbits.LATB5 |
#endif |
/** S W I T C H *****************************************************/ |
#define mInitSwitch() TRISCbits.TRISC2 = 1; |
#define UserSW PORTCbits.RC2 |
#define mLED_Both_Off() {mLED_1_Off(); mLED_2_Off();} |
#define mLED_Both_On() {mLED_1_On(); mLED_2_On();} |
#define mLED_Only_1_On() {mLED_1_On(); mLED_2_Off();} |
#define mLED_Only_2_On() {mLED_1_Off(); mLED_2_On();} |
#endif //HARDWARE_PROFILE_PICDEM_FSUSB_H |
/Modules/Clock/CLKGEN01A/SW/DG8SAQ synthesiser_Emulator/user.bak |
---|
0,0 → 1,197 |
/********************************************************************* |
* |
* Microchip USB C18 Firmware Version 1.2 |
* |
********************************************************************* |
* FileName: user.h |
* Dependencies: See INCLUDES section below |
* Processor: PIC18 |
* Compiler: C18 3.11+ |
* Company: Microchip Technology, Inc. |
* |
* Software License Agreement |
* |
* The software supplied herewith by Microchip Technology Incorporated |
* (the Company) for its PICmicro® Microcontroller is intended and |
* supplied to you, the Companys customer, for use solely and |
* exclusively on Microchip PICmicro Microcontroller products. The |
* software is owned by the Company and/or its supplier, and is |
* protected under applicable copyright laws. All rights are reserved. |
* Any use in violation of the foregoing restrictions may subject the |
* user to criminal sanctions under applicable laws, as well as to |
* civil liability for the breach of the terms and conditions of this |
* license. |
* |
* THIS SOFTWARE IS PROVIDED IN AN AS IS CONDITION. NO WARRANTIES, |
* WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED |
* TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
* PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, |
* IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR |
* CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. |
* |
* Author Date Comment |
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
* Rawin Rojvanit 11/19/04 Original. |
* Rawin Rojvanit 05/14/07 Minor updates. |
********************************************************************/ |
#ifndef PICDEM_FS_DEMO_H |
#define PICDEM_FS_DEMO_H |
/** I N C L U D E S **********************************************************/ |
/** D E F I N I T I O N S ****************************************************/ |
// For custom LPF switchover points |
#define ALEX |
//#define K5OOR |
//#define MARC |
// YAS is defined in the HardwareProfile - UBW.h, if needed |
#if defined(YAS) |
#define NUM_BPF 8 |
#else |
#define NUM_BPF 4 |
#endif |
#define INIT_SI570_ON_STARTUP |
#define VERSION_MAJOR 16 |
#define VERSION_MINOR 04 |
#define DEFAULT_I2C_ADDRESS 0x55 |
#define PCF8574 0x39 // A2 A1 A0 -> 0 0 1 |
#define F_CAL_DONE 0 // EEPROM position of F_CAL_DONE flag. 4 bytes follow. |
#define F_CAL_DONE_VALUE 0x55 |
#define DEFAULT_FCRYST 114.285 |
//#if defined(UBW) |
#define F_INIT_FREQ 5 // 4 bytes follow |
//#elif defined(UBW32) |
//#define F_INIT_FREQ 2 // fcryst 4 bytes all stored in one 32 bit slot |
#endif |
#define F_INIT_FREQ_VALUE 0x55 |
#define DEFAULT_INIT_FREQ 56.32 |
#if defined(UBW) |
#define F_SMOOTH 10 // 2 bytes follow |
#elif defined(UBW32) |
#define F_SMOOTH 4 // 1 slot follow |
#endif |
#define F_SMOOTH_VALUE 0x55 |
#define DEFAULT_SMOOTH 3500 // ppm |
#define F_SUB_MUL_VALUE 0x55 |
#define DEFAULT_SUB 0.0 |
#define DEFAULT_MUL 1.0 |
#if defined(UBW) |
#define F_SUB_MUL 13 // 8 bytes follow |
#elif defined(UBW32) |
#define F_SUB_MUL 6 // 2 slots follow |
#endif |
#if defined(UBW) |
#define F_CROSS_OVER 22 // 32 bytes follow |
#elif defined(UBW32) |
#define F_CROSS_OVER 9 // 16 words stored in 16 (unsigned int) slots |
#endif |
#define F_CROSS_OVER_VALUE 0x55 |
#if defined(UBW) |
#define F_BLINK_LED 55 |
#elif defined(UBW32) |
#define F_BLINK_LED 26 |
#endif |
/** S T R U C T U R E S ******************************************************/ |
extern BYTE i2c_adr; |
extern BYTE command; |
extern BYTE replybuf[8]; |
extern WORD wCount; |
#define COMMAND_BUFFER_SIZE 16 |
#define DATA_PACKET_SIZE 6 |
typedef struct COMMAND_BUFFER |
{ |
BYTE command; |
WORD wCount; |
BYTE data[DATA_PACKET_SIZE]; |
} COMMAND_BUFFER_t; |
extern COMMAND_BUFFER_t command_buffer[COMMAND_BUFFER_SIZE]; |
extern BYTE current_command_in, current_command_out; |
extern BYTE command_count; |
extern double set_frequency; |
extern unsigned char tempBuf[8]; |
typedef union _avr_freq |
{ |
unsigned long qw; |
unsigned char bytes[4]; |
} avr_freq_t; |
extern avr_freq_t avr_freq, fcryst_freq; //frequency [MHz]*2^21 |
// fcryst freq [MHz]*2^24 |
extern avr_freq_t f_mul; // mul for set freq in 11.21 format |
typedef union _offset |
{ |
long qw; // signed offset in 11.21 format |
unsigned char bytes[4]; |
} offset_t; |
extern offset_t f_sub; |
extern unsigned char registers[6]; |
extern BYTE abpf_flag; |
extern double Smooth_double; |
extern double fcryst_double; |
extern WORD_VAL FilterCrossOver[8]; // 11.5 bit value Mhz |
extern float FilterSwitchOver[7]; |
extern WORD_VAL LPFCrossOver[8]; |
extern float LPFSwitchOver[7]; |
/** P U B L I C P R O T O T Y P E S *****************************************/ |
void UserInit(void); |
void ProcessIO(void); |
void Set_Freq_Handler(void); |
void Set_Register_Handler(void); |
void Set_Cal_Handler(void); |
void Set_Init_Freq_Handler(void); |
void Set_Smooth_Handler(void); |
void Set_Sub_Mul_Handler(void); |
void Reset_Si570(void); |
void Freeze (void); |
void Unfreeze (void); |
void Prep_rd (unsigned short); |
void WriteBk (void); |
void NewF (void); |
void SetNewFreq(void); |
void ReadRegs(void); |
void ReadStartUpConfiguration(void); |
void RunFreqProg(double); |
void SetFrequency(double); |
void Set_BPF(float); |
void Set_LPF(float); |
float Cross2Switch(WORD_VAL); |
WORD_VAL Switch2Cross(float); |
double Freq_From_Register(double); |
void Read_Command_Into_Buffer(void); |
void USBCheckUserRequest(void); |
void USBCheckUBWRequest(void); |
#endif //PICDEM_FS_DEMO_H |