📄 analog_values.c
字号:
/******************************************************************************
*
* Freescale Semiconductor Inc.
* (c) Copyright 2004-2005 Freescale Semiconductor, Inc.
* ALL RIGHTS RESERVED.
*
*******************************************************************************
*
* @file analog_values.c
*
* @author r89994
*
* @version 1.0.0.0
*
* @date Mar-30-2006
*
* @brief Here are functions used in execute.c switches
*
********************************************************************************/
#include "main.h"
#include "analog_values.h"
#include "spi.h"
#include "hidef.h"
/********************************************************************************
* Global Variables
*********************************************************************************/
extern Byte fm_status, fm_task, fm_action0, fm_action1, fm_action2, fm_action3,
fm_action4, fm_action5, fm_action6, fm_action7, fm_action8, fm_action9,
fm_action10, fm_action11, fm_action12, fm_action13, fm_action14;
extern Byte last_action0, last_action1, last_action2, last_action3,
last_action4, last_action5, last_action6, last_action7, last_action8,
last_action9, last_action10, last_action11, last_action12, last_action13,
last_action14;
extern Word fm_analog1, fm_analog2, fm_analog3, fm_analog4, fm_analog5,
fm_analog6, fm_analog7, fm_analog11, fm_analog12, fm_analog13,
fm_analog14, fm_analog21, fm_analog22, fm_analog23, fm_analog24;
extern Byte lastmsgU201, lastmsgU202;
extern UNION16 lastmsgU401, lastmsgU402, lastmsgU403, lastmsgU501, lastmsgU601, lastmsgU605;
extern SPI24 lastmsgU404, lastmsgU405;
extern Byte countercheck; // counter of cycles 30 ms; value is <0,7>
extern TASK arrayTask[SIZE_TASK_ARRAY];
extern Byte actualTask; // pointer to actualy solved task in arrayTask
/******************************************************************************
* Module : analog_ambient_temperature
* Description : measured analog value on MSDI on SG8 Pin
* Global Data : fm_analog3
* Static Global Data: none
* Returns : none
* Arguments : none
* Special Issues : none
******************************************************************************/
void Analog_ambient_temperature(void)
{
Byte temp8;
UNION16 temp16;
SPI24 temp24;
for (temp8=0; temp8 < WAIT_50; temp8++);
CSB_U405 = 0;
lastmsgU405.comm = U405_ANALOG_COMMAND;
lastmsgU405.data.w = U405_ANALOG_SG8;
temp24 = ReadWriteSPI24bit(lastmsgU405);
CSB_U405 = 1;
for (temp8=0; temp8 < WAIT_100; temp8++);
ATD0CTL5 = ATD0CTL5_DJM_MASK | ATD0CTL5_CC_MASK; // ATD0 ch1, right justif., ch1 starts
while(!ATD0STAT0_SCF); // wait till conversion is completed + clear scf flag when set
fm_analog3 = (ATD0DR0/11); // read data => clear conversion complete flags
}
/******************************************************************************
* Module : analog_light_intensity
* Description : measured analog value on MSDI on SG9 Pin
* Global Data : fm_analog4
* Static Global Data: none
* Returns : none
* Arguments : none
* Special Issues : none
******************************************************************************/
void Analog_light_intensity(void)
{
Byte temp8;
UNION16 temp16;
SPI24 temp24;
for (temp8=0; temp8 < WAIT_50; temp8++);
CSB_U405 = 0;
lastmsgU405.comm = U405_ANALOG_COMMAND;
lastmsgU405.data.w = U405_ANALOG_SG9;
temp24 = ReadWriteSPI24bit(lastmsgU405);
CSB_U405 = 1;
for (temp8=0; temp8 < WAIT_100; temp8++);
ATD0CTL5 = ATD0CTL5_DJM_MASK | ATD0CTL5_CC_MASK; // ATD0 ch1, right justif., ch1 starts
while(!ATD0STAT0_SCF); // wait till conversion is completed + clear scf flag when set
fm_analog4 = ATD0DR0; // read data => clear conversion complete flags
}
/******************************************************************************
* Module : analog_voltage1
* Description : measured analog value on MSDI on SG11 Pin
* Global Data : fm_analog1
* Static Global Data: none
* Returns : none
* Arguments : none
* Special Issues : none
******************************************************************************/
void Analog_voltage1(void)
{
Byte temp8;
UNION16 temp16;
SPI24 temp24;
for (temp8=0; temp8 < WAIT_50; temp8++);
CSB_U405 = 0;
lastmsgU405.comm = U405_ANALOG_COMMAND;
lastmsgU405.data.w = U405_ANALOG_SG11;
temp24 = ReadWriteSPI24bit(lastmsgU405);
CSB_U405 = 1;
for (temp8=0; temp8 < WAIT_100; temp8++);
ATD0CTL5 = ATD0CTL5_DJM_MASK | ATD0CTL5_CC_MASK; // ATD0 ch1, right justif., ch1 starts
while(!ATD0STAT0_SCF); // wait till conversion is completed + clear scf flag when set
fm_analog1 = ATD0DR0; // read data => clear conversion complete flags}
}
/******************************************************************************
* Module : analog_voltage2
* Description : measured analog value on MSDI on SG12 Pin
* Global Data : fm_analog2
* Static Global Data: none
* Returns : none
* Arguments : none
* Special Issues : none
******************************************************************************/
void Analog_voltage2(void)
{
Byte temp8;
UNION16 temp16;
SPI24 temp24;
for (temp8=0; temp8 < WAIT_50; temp8++);
CSB_U405 = 0;
lastmsgU405.comm = U405_ANALOG_COMMAND;
lastmsgU405.data.w = U405_ANALOG_SG12;
temp24 = ReadWriteSPI24bit(lastmsgU405);
CSB_U405 = 1;
for (temp8=0; temp8 < WAIT_100; temp8++);
ATD0CTL5 = ATD0CTL5_DJM_MASK | ATD0CTL5_CC_MASK; // ATD0 ch1, right justif., ch1 starts
while(!ATD0STAT0_SCF); // wait till conversion is completed + clear scf flag when set
fm_analog2 = ATD0DR0; // read data => clear conversion complete flags
}
/******************************************************************************
* Module : analog_jaguar_temperature
* Description : measured analog value on MSDI on SP1 Pin
* Global Data : fm_analog6
* Static Global Data: none
* Returns : none
* Arguments : none
* Special Issues : none
******************************************************************************/
void Analog_jaguar_temperature(void)
{
Byte temp8;
UNION16 temp16;
SPI24 temp24;
for (temp8=0; temp8 < WAIT_50; temp8++);
CSB_U405 = 0;
lastmsgU405.comm = U405_ANALOG_COMMAND;
lastmsgU405.data.w = U405_ANALOG_SP1;
temp24 = ReadWriteSPI24bit(lastmsgU405);
CSB_U405 = 1;
for (temp8=0; temp8 < WAIT_100; temp8++);
ATD0CTL5 = ATD0CTL5_DJM_MASK | ATD0CTL5_CC_MASK; // ATD0 ch1, right justif., ch1 starts
while(!ATD0STAT0_SCF); // wait till conversion is completed + clear scf flag when set
fm_analog6 = ATD0DR0; // read data => clear conversion complete flags
}
/******************************************************************************
* Module : analog_jaguar_current_hso
* Description : measured analog value on MC33892 on HS0 Pin
* Global Data : fm_analog11
* Static Global Data: none
* Returns : none
* Arguments : none
* Special Issues : none
******************************************************************************/
void Analog_jaguar_current_hso(void)
{
Byte temp8;
UNION16 temp16;
SPI24 temp24;
CSB_U401 = 0; // Chipselect e-Switch MC33580 U401 - PORTB3
temp16.BYTES.msB = U401_OCR1;
temp16.BYTES.lsB = U401_HS0;
temp16 = ReadWriteSPI16bit(temp16);
CSB_U401 = 1;
for (temp8=0; temp8 < WAIT_100; temp8++);
ATD0CTL5 = ATD0CTL5_DJM_MASK; // ATD0 ch0, right justif., ch0 starts
while(!ATD0STAT0_SCF); // wait till conversion is completed + clear scf flag when set
fm_analog11 = ATD0DR0; // read data => clear conversion complete flags
CSB_U401 = 0; // Chipselect e-Switch MC33580 U401 - PORTB3
temp16.BYTES.msB = U401_OCR1;
temp16.BYTES.lsB = U401_NO_HS;
temp16 = ReadWriteSPI16bit(temp16);
CSB_U401 = 1;
}
/******************************************************************************
* Module : analog_jaguar_current_hs1
* Description : measured analog value on MC33892 on HS1 Pin
* Global Data : fm_analog12
* Static Global Data: none
* Returns : none
* Arguments : none
* Special Issues : none
******************************************************************************/
void Analog_jaguar_current_hs1(void)
{
Byte temp8;
UNION16 temp16;
SPI24 temp24;
CSB_U401 = 0; // Chipselect e-Switch MC33580 U401 - PORTB3
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -