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

📄 controllbuttons.c

📁 freescale最新的16位单片机
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************
*
* Freescale Semiconductor Inc.
* (c) Copyright 2004-2005 Freescale Semiconductor, Inc.
* ALL RIGHTS RESERVED.
*
*******************************************************************************
*
* @file      controllbuttons.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 "controllbuttons.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 Byte     failSBC;                  

extern TASK     arrayTask[SIZE_TASK_ARRAY];
extern Byte     actualTask;     // pointer to actualy solved task in arrayTask                  

/******************************************************************************
* Module            : lights_55W_OFF
* Description       : switch off the 55W lights
* Global Data       : none
* Static Global Data: none
* Returns           : none
* Arguments         : none
* Special Issues    : none
******************************************************************************/
void Lights_55W_OFF(void)
{
Byte        temp8;
UNION16     temp16;
SPI24       temp24;
    
    CSB_U401 = 0;        // Chipselect e-Switch MC33580 U401 - PORTB3
    lastmsgU401.BYTES.msB = U401_OCR0;
    lastmsgU401.BYTES.lsB = U401_NO_HS;
    temp16 = ReadWriteSPI16bit(lastmsgU401);
    CSB_U401 = 1; 
}
/******************************************************************************
* Module            : lights_55W_ON
* Description       : switch on the 55W lights, NOT detect undervoltage
* Global Data       : none
* Static Global Data: none
* Returns           : none
* Arguments         : none
* Special Issues    : undervoltage is detected via UV detection on SBC - 
*                   : is unreliable way
******************************************************************************/
void Lights_55WA_on(void)
{
Byte        temp8;
UNION16     temp16;
SPI24       temp24;
char        i;
      
  CSB_U401 = 0;        // Chipselect e-Switch MC33580 U401 - PORTB3
  lastmsgU401.BYTES.msB = U401_UOVR;
  lastmsgU401.BYTES.lsB = (U401_UOVR_OFF);		//Undervoltage/Overvoltage protection off
  temp16 = ReadWriteSPI16bit(lastmsgU401);
  CSB_U401 = 1;
  CSB_U401 = 0;        // Chipselect e-Switch MC33580 U401 - PORTB3
  lastmsgU401.BYTES.msB = U401_OCR0;
  lastmsgU401.BYTES.lsB = (U401_HS0);		      //lightA ON
  temp16 = ReadWriteSPI16bit(lastmsgU401);
  CSB_U401 = 1; 
}
/******************************************************************************
* Module            : lights_55W_ON
* Description       : switch on the 55W lights, NOT detect undervoltage
* Global Data       : none
* Static Global Data: none
* Returns           : none
* Arguments         : none
* Special Issues    : undervoltage is detected via UV detection on SBC - 
*                   : is unreliable way
******************************************************************************/
void Lights_55WB_on(void)
{
Byte        temp8;
UNION16     temp16;
SPI24       temp24;
char        i;
    
  CSB_U401 = 0;        // Chipselect e-Switch MC33580 U401 - PORTB3
  lastmsgU401.BYTES.msB = U401_OCR0;
  lastmsgU401.BYTES.lsB = (U401_HS1|U401_HS0);		//lightB ON
  temp16 = ReadWriteSPI16bit(lastmsgU401);
  CSB_U401 = 1;
 
  for(i=0; i< 4; i++)		// not the most ideal solution, need to be change in cause of too long delay
  {											// MCU is for 24ms not capable to detect any changes on the Board
    Delay6ms();		      // delay time because of power supply stability
  }
  CSB_U401 = 0;         // Chipselect e-Switch MC33580 U401 - PORTB3
  lastmsgU401.BYTES.msB = U401_UOVR;
  lastmsgU401.BYTES.lsB = (U401_UOVR_ON);		//Undervoltage/Overvoltage protection on
  temp16 = ReadWriteSPI16bit(lastmsgU401);
  CSB_U401 = 1;
}
/******************************************************************************
* Module            : analog_button_selection
* Description       : 
* Global Data       : fm_analog5
* Static Global Data: none
* Returns           : none
* Arguments         : none
* Special Issues    : this function is not called ever
******************************************************************************/
void Analog_button_selection(void)
{
Byte        temp8;
UNION16     temp16;
SPI24       temp24;
  
  CSB_U405 = 0;
  lastmsgU405.comm = U405_ANALOG_COMMAND;
  lastmsgU405.data.w = U405_ANALOG_SG10;
  temp24 = ReadWriteSPI24bit(lastmsgU405);         
  CSB_U405 = 1;
  for (temp8=0; temp8 < WAIT_60; 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
  temp16.w = ATD0DR0;

  if BUTTON_NO_BUTTON
      temp16.w = 0;
  if BUTTON_1
      temp16.w = 1;
  if BUTTON_2
      temp16.w = 2;
  if BUTTON_1_2
      temp16.w = 12;
  if BUTTON_3
      temp16.w = 3;
  if BUTTON_1_3
      temp16.w = 13;
  if BUTTON_2_3
      temp16.w = 23;
  if BUTTON_1_2_3
      temp16.w = 123;
  if BUTTON_4
      temp16.w = 4;
  if BUTTON_1_4
      temp16.w = 14;
  if BUTTON_2_4
      temp16.w = 24;
  if BUTTON_1_2_4
      temp16.w = 124;
  if BUTTON_3_4
      temp16.w = 34;
  if BUTTON_1_3_4
      temp16.w = 134;
  if BUTTON_2_3_4
      temp16.w = 234;
  if BUTTON_1_2_3_4
      temp16.w = 1234;

  fm_analog5 = temp16.w;
}
/******************************************************************************
* Module            : lights_5W_OFF
* Description       : switch off the 55W lights
* Global Data       : none
* Static Global Data: none
* Returns           : none
* Arguments         : none
* Special Issues    : none
******************************************************************************/

void Lights_5W_off(void)
{
Byte        temp8;
UNION16     temp16;
SPI24       temp24;
  
  CSB_U402 = 0;        // Chipselect e-Switch MC33874 U402 - PORTK7
  lastmsgU402.BYTES.msB = U402_OCR0;
  lastmsgU402.BYTES.lsB = U402_NO_HS;
  temp16 = ReadWriteSPI16bit(lastmsgU402);
  CSB_U402 = 1;
}
/******************************************************************************
* Module            : lights_5W_ON
* Description       : switch on the 5W lights
* Global Data       : none
* Static Global Data: none
* Returns           : none
* Arguments         : none
* Special Issues    : none
******************************************************************************/

void Lights_5W_on(void)
{
Byte        temp8;
UNION16     temp16;
SPI24       temp24;  
  
  CSB_U402 = 0;        // Chipselect e-Switch MC33874 U402 - PORTK7
  lastmsgU402.BYTES.msB = U402_OCR0;
  lastmsgU402.BYTES.lsB = (U402_HS0 | U402_HS1 | U402_HS2 | U402_HS3);
  temp16 = ReadWriteSPI16bit(lastmsgU402);
  CSB_U402 = 1;
}
/******************************************************************************
* Module            : cabin_lights_1_off
* Description       : switch off the cabin lights
* Global Data       : none
* Static Global Data: none
* Returns           : none
* Arguments         : none
* Special Issues    : none
******************************************************************************/
  
void Cabin_lights_1_off(void)
{
Byte        temp8;
UNION16     temp16;
SPI24       temp24;  

    CSB_U403 = 0;        // Chipselect COSS MC33880 U403 - PAD13
    lastmsgU403.BYTES.msB = U403_OPEN_LOAD_ON;

⌨️ 快捷键说明

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