【TI首届低功耗设计大赛】手持温度心电监测仪(综合帖)
[复制链接]
本帖最后由 hh376158101 于 2015-1-5 23:59 编辑
说说我设计这个手持式监护仪的缘由吧。记得高考那年,因为身体原因住进了医院,在医院住了挺久,每天都要进行两次体温检测,使用的是常规的水银体温计,由于所在的是省里的大医院,所以病号特别多,每一层200多个病号。每一个病号都要分发、回收体温计。护士们都是通过纸笔记录测量数据,回到护士站一一输入系统。所以护士姐姐的工作量还是挺大的。难怪她们经常抱怨,医生动动嘴,护士跑断腿,呵呵。在医院住了挺久,换了好几个病友,又一次因为军区医院的干部病房告急,就把一个部队首长安排跟我一起住。待遇就是不一样啊,有专人服侍,而且心电检测等许多常规检查都是上门服务,同样都是病号,差别怎么就那么大呢,呵呵。那么问题来了,为了减轻护士工作负担,同时解决医疗资源合理分配的问题,我打算设计一款能够进行非接触式测温,能够测量保存多组数据,最后将数据通过蓝牙发送至护士站电脑的手持终端,稍后,还会拓展心电监测功能。
说说系统框架。
首先,本次大赛要求基于金刚狼套件,所以launchpad 的IO口对设计有一定的限制。下图为金刚狼launchpad的各类硬件接口示意图。
从接口示意图中,我们了解到该launchpad预留了一路硬件SPI、UART,已经两路模拟输入接口,I2C接口通过软件模拟。使用了这些接口之后,省下的IO已经不多,所以我们要考虑周全,好好利用这些接口。 通过网络查找相关资料,最终得到了如下图所示的系统框图。
非接触式测温: 我们使用的是MLX90615热电堆传感器。该传感器在人体体温范围内,精度达到0.02摄氏度。其通过I2C接口与单片机进行通信。 显示部分: 由于msp430fr5969没有提供段式LCD驱动器,而且对功耗的要求相对较高,所以我选择了cog12864低功耗点阵液晶。单片机通过SPI接口与其通信。 数据存储: RF5969提供了64KBFRAM,用于温度、时间的存储足够,可是用于存储心电信号数据就捉襟见肘了,,所以我拓展了一片外置存储器,期初想使用富士通的1M的FRAM,看了下价格,却步了。最后我使用了512K的EEPROM,跟富士通I2C接口的FRAM存储器接口一样,日后,有需要可以随时更换。 键盘: 当初我考虑过普通的IO矩阵键盘、AD键盘。不过由于IO有限,第一种方案放弃。AD键盘存在一定的不确定性,对于医疗设备这种要求严苛的设备老说不太适合。所以最后,我选择了通过键盘芯片来拓展。我使用的是TI的TCA8418,其最大可支持80个按键,有键盘模式和普通IO模式可供我们配置,可向单片机提供中断信号,通过I2C接口与单片机通信。 蓝牙模块: 蓝牙模块通过串口与单片机通信。两个蓝牙模块使用透传模式。 电池电量检测: 电池电量检测使用TI的BQ27010,其通过I2C总线与单片机进行通信。 ECG心电监测: 心电监测模拟前端选择TI公司的ADS1294四通道模拟前端,可实现5导联的心电监测。
四肢电极RA\LA\LL经过差分放大器做差,分别得到四肢导联I、导联II、导联III、四肢电极RL作为电势零点、威尔逊中心终端电势为四肢电极RA\LA\LL的平均电势,其作为胸部导联的参考电势,经差分放大得到胸部导联V1。
电源部分:
电源使用锂电池供电,所以我使用了,TPS63021DCDC芯片。
以下是原理图:
软件:
TCA8418驱动:
- /**************************************************************************************************************************************************
- * Included Headers *
- **************************************************************************************************************************************************/
- #include "MSP430.h" // Empty header file to allow global changes in one header file
- #include "I2C.h"
- #include "TCA8418_Key_Scan.h" // Definition file for TCA8418 Registers
- /**************************************************************************************************************************************************
- * External Variables *
- **************************************************************************************************************************************************/
- extern char TCA8418_Packet_Data[];
- /**************************************************************************************************************************************************
- * Initialize_Keyboard *
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Initializes the TCA8418 Keyboard
- *
- * @param[in] device_slot Location of the CC Radio on the MAVRK Motherboard
- *
- * @return NONE
- *
- **************************************************************************************************************************************************/
- void Initialize_Keyboard()
- {
- Init_TCA8418(TCA8418_I2C_SLAVE_ADDRESS); // Initialize TCA8418 Component
-
- //Initialize_Keylock ();
-
- Enable_TCA8418_Interrupts();
-
- }
- /**************************************************************************************************************************************************
- * Initialize_Keylock *
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Initializes the TCA8418 Keyboard keypad lock/unlock feature
- *
- * @param[in] device_slot Location of the CC Radio on the MAVRK Motherboard
- *
- * @return NONE
- *
- **************************************************************************************************************************************************/
- void Initialize_Keylock ()
- {
-
- // USe SHIFT Key & 0 Key as keypad unlock keys
- Set_TCA8418_Keylock_Unlock_Values (SHIFT_SWITCH, SWITCH_0, TCA8418_I2C_SLAVE_ADDRESS);
-
- // 1 second timeout between 1st unlock key press and 2nd unlock key press
- Set_TCA8418_Keylock_Timer_Value (TCA8418_1_SEC, TCA8418_I2C_SLAVE_ADDRESS);
- // 1 second interrupt timer mask
- Set_TCA8418_Keylock_Interrupt_Mask_Timer_Value (TCA8418_1_SEC, TCA8418_I2C_SLAVE_ADDRESS);
- // This function can be used if the initial state desired is to have the keypad unlocked
- Disable_TCA8418_Keylock(TCA8418_I2C_SLAVE_ADDRESS);
- // Enable Keypad Lock Interrupt which signals detection of correct unlock key1 and key2 which unlocks of keypad
- Enable_TCA8418_Keypad_Lock_Interrupt (TCA8418_I2C_SLAVE_ADDRESS);
- }
- /**************************************************************************************************************************************************
- * Enable_TCA8418_Interrupts *
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Enable TCA8418 Component Data_Ready Interrupt
- *
- * @param[in] device_slot Location of the CC Radio on the MAVRK Motherboard
- *
- * @return NONE
- *
- **************************************************************************************************************************************************/
- void Enable_TCA8418_Interrupts ()
- {
- //写1清中断标志位
- Clear_TCA8418_Interrupt_Status(TCA8418_ALL_INTERRUPT_FLAGS, TCA8418_I2C_SLAVE_ADDRESS); // Clear all interrupt status bits in TCA8418 device
- Enable_TCA8418_Key_Event_Interrupt( TCA8418_I2C_SLAVE_ADDRESS); // Enable interrupt for Key press Events on Keypad
- }
- /*TCA8418使用指南*/
- //***************TCA8418初始化*******************/
- //配置寄存器清零
- //将FIFO内键值全部读出(清空FIFO)
- //配置键盘IO
- //设置MCU中断IO,负责接收TCA8418中断请求
- //**************键盘锁初始化********************/
- //设置键盘锁的值(两个组合键,解锁)
- //设置第一解锁键与第二解锁键的时间间隔
- //设置键盘锁中断屏蔽时间
- //不使能键盘锁(根据需要设置)
- //使能键盘锁中断
- /***************使能中断***********************/
- //清除中断状态寄存器的标志位
- //使能按键事件中断
- //**************按键检测及处理*****************/
- //关闭按键事件中断
- //读取中断状态寄存器,查看是什么引起的中断
- //如果是解锁中断,则打开键盘锁,停止键盘锁中断
- //如果是按键事件中断,则查看键盘锁状态寄存器,看键盘
- //是否处于锁定状态,如果是,不处理,如果不是,则读取
- //键值,之后清除中断状态寄存器,使能按键事件中断
- //这就完成里一个键值的读取工作
- unsigned char TCA8418_Key_Event_Buffer[TCA8418_KEY_EVENT_BUFFER_SIZE];
- unsigned char TCA8418_Key_Events_In_Buffer_Size;
- TCA8418_Interrupt_Status_register_type TCA8418_Interrupt_Status_register;
- /*************************************************************************************************************************************************/
- /* This section of code contains public functions that are generally used by standard applications. The parameter sets for public API functions */
- /* provide an abstraction layer that will be maintained throughout updates and changes to underlying processor functions. */
- /* */
- /*! \cond PUBLIC */
- /*************************************************************************************************************************************************/
- /**************************************************************************************************************************************************
- * Read_TCA8418_Register
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Read an I2C register value from a TCA8418 Device
- *
- * The function will read an I2C register value from a TCA8418 Device.
- *
- * @param[in] register_address TCA8418 I2C register address to be read
- * @param[out] read_data Pointer to variable where data read from TCA8418 register is stored
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- unsigned char Read_TCA8418_Register (unsigned char register_address, unsigned char I2C_slave_address)
- {
- return (IIC_ReadByte(I2C_slave_address, register_address));
- }
- /**************************************************************************************************************************************************
- * Write_TCA8418_Register
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Write a value to an I2C register in the TCA8418 Keypad Scan Device
- *
- * The function will write a value to an I2C register in the TCA8418 Keypad Scan Device.
- *
- * @param[in] register_address TCA8418 I2C register address to be written
- * @param[in] write_data Pointer to value to be written to the specified TCA8418 register
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- void Write_TCA8418_Register (unsigned char register_address, unsigned char write_data, unsigned char I2C_slave_address)
- {
- IIC_WriteByte(I2C_slave_address, register_address, write_data);
- }
- /**************************************************************************************************************************************************
- * Config_TCA8418_Row_Col_Keyscan_GPIO_Function
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Configure the TCA8418 Row Column Pin Function
- *
- * This function configures the TC8418 keyscan ROW-COLUMNS to the layout of key switches on RF-TCA8418-MVK module
- *
- * @param[in] device_slot Defines slot where RF-TCA8418-MVK module is plugged into MB-PRO-MVK motherboard
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- void Config_TCA8418_Row_Col_Keyscan_GPIO_Function (unsigned char I2C_slave_address)
- {
- Write_TCA8418_Register (TCA8418_KEYSCAN_GPIO_FUNCTION_1_REGISTER, 0X1F, I2C_slave_address);
- Write_TCA8418_Register (TCA8418_KEYSCAN_GPIO_FUNCTION_2_REGISTER, 0X0F, I2C_slave_address);
-
- Write_TCA8418_Register (TCA8418_KEYSCAN_GPIO_FUNCTION_3_REGISTER, 0X00, I2C_slave_address);
- }
-
- /**************************************************************************************************************************************************
- * Enable_TCA8418_Key_Event_Interrupt
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Enable the TCA8418 Key Event Interrupt
- *
- * This function sets the state of the TC8418 Key Event Interrupt to ENABLE
- *
- * @param[in] device_slot Defines slot where RF-TCA8418-MVK module is plugged into MB-PRO-MVK motherboard
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- void Enable_TCA8418_Key_Event_Interrupt ( unsigned char I2C_slave_address)
- {
- unsigned char TCA8418_Configuration = 0X00;
- TCA8418_Configuration = Read_TCA8418_Register (TCA8418_CONFIGURATION_REGISTER, I2C_slave_address);
-
- TCA8418_Configuration = TCA8418_Configuration | 0X01 ;
-
- Write_TCA8418_Register (TCA8418_CONFIGURATION_REGISTER, TCA8418_Configuration, I2C_slave_address);
- }
- /**************************************************************************************************************************************************
- * Disable_TCA8418_Key_Event_Interrupt
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Disable the TCA8418 Key Event Interrupt
- *
- * This function sets the state of the TC8418 Key Event Interrupt to DISABLE
- *
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- void Disable_TCA8418_Key_Event_Interrupt ( unsigned char I2C_slave_address)
- {
- unsigned char TCA8418_Configuration = 0X00 ;
- TCA8418_Configuration = Read_TCA8418_Register (TCA8418_CONFIGURATION_REGISTER,I2C_slave_address);
-
- TCA8418_Configuration = TCA8418_Configuration & 0XFE ;
-
- Write_TCA8418_Register (TCA8418_CONFIGURATION_REGISTER, TCA8418_Configuration, I2C_slave_address);
- }
- /**************************************************************************************************************************************************
- * Get_TCA8418_Key_Event
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Get the Key Event from the TCA8418 Key Event FIFO
- *
- * This function gets the data for single key event data from the TC8418.
- *
- * @param[out] key_event Pointer to variable used to store key_event data read from TCA8418 register
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- unsigned char Get_TCA8418_Key_Event ( unsigned char I2C_slave_address)
- {
-
- return Read_TCA8418_Register (TCA8418_KEY_EVENT_0_REGISTER,I2C_slave_address);
- }
- /**************************************************************************************************************************************************
- * Get_TCA8418_Key_Event_Count
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Gets the number of Key Events stored in the TCA8418 Event FIFO
- *
- * This function gets the current Event Count (Number of Key and/or GPIO-Input Events in the ten deep FIFO)
- *
- * @param[out] event_count Pointer to variable used to store event_count
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- unsigned char Get_TCA8418_Key_Event_Count (unsigned char I2C_slave_address)
- {
- return Read_TCA8418_Register (TCA8418_KEY_LOCK_AND_EVENT_COUNTER_REGISTER,I2C_slave_address);
- }
- /********************************************************************************************************************************
- * Move_Key_Events_From_TCA8418_FIFO_To_Buffer
- ********************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Drain TC8418 Key Event FIFO until empty, while storing Key Event data to Buffer
- *
- * This function will move all the Key_Events in the TCA8418 Key_Event FIFO into an application supplied key_event Buffer
- *
- * @param[out] key_event_buffer Pointer to application supplied Key Event Buffer
- * @param[in] key_event_buffer_size Defines size of application key event buffer to prevent writing past end of buffers
- * @param[out] number_of_key_events_in_buffer Pointer to variable used to store the number of key events moved from the TCA8418 FIFO
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- ********************************************************************************************************************************/
- void Move_Key_Events_From_TCA8418_FIFO_To_Buffer (unsigned char* key_event_buffer,
- unsigned char key_event_buffer_size,
- unsigned char number_of_key_events_in_buffer,
- unsigned char I2C_slave_address)
- {
- unsigned char buffer_index = 0;
- unsigned char key_event;
- unsigned char number_of_key_events_in_fifo;
- unsigned char number_of_buffer_key_events = 0;
-
- // Get the current count of Key/GPIO Events in the Event FIFO
- number_of_key_events_in_fifo = Get_TCA8418_Key_Event_Count (I2C_slave_address);
-
- // Drain the TCA8418 Key/GPIO Event FIFO. The Event Count Register(Number of Events in FIFO)
- // must be zero before the Interrupt Status Bit "K_INT" can be cleared
- do
- {
- Get_TCA8418_Key_Event (I2C_slave_address);
-
- // Copy Key_Event to output Key_Event Buffer
- // Increment number of key events stored in output Buffer
- // Increment outut buffer array index for storage of next key event
- key_event_buffer [buffer_index] = key_event;
- ++number_of_buffer_key_events;
- ++buffer_index;
-
- // Get the current count of Key/GPIO Events in the Event FIFO
- // It should be one less than previous count, unless a new key event occured
- Get_TCA8418_Key_Event_Count (I2C_slave_address);
- // Keep moving Key Event data from TCA8418 FIFO to Buffer until FIFO is drained
- // or Output Buffer is Full based on defined size
- } while ((number_of_key_events_in_fifo > 0) && (buffer_index <= key_event_buffer_size));
-
-
- // Copy the number of key events that have been stored in the key_Event_Buffer for
- // use by the calling function for retrieval/processing of key_events
- number_of_key_events_in_buffer = number_of_buffer_key_events;
- }
- /********************************************************************************************************************************
- * Enable_TCA8418_GP_Input_Event_Interrupt
- ********************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Enables the GPIO Pin Event interrupt
- *
- * This function will enable the GPIO Input(Row or Col) Pin Event interrupt
- *
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- ********************************************************************************************************************************/
- void Enable_TCA8418_GP_Input_Event_Interrupt (unsigned char I2C_slave_address)
- {
- unsigned char TCA8418_Configuration = 0X00 ;
-
- TCA8418_Configuration = Read_TCA8418_Register (TCA8418_CONFIGURATION_REGISTER, I2C_slave_address);
- TCA8418_Configuration = TCA8418_Configuration | 0X02 ;
-
- Write_TCA8418_Register (TCA8418_CONFIGURATION_REGISTER, TCA8418_Configuration, I2C_slave_address);
- }
- /********************************************************************************************************************************
- * Disable_TCA8418_GP_Input_Event_Interrupt
- ********************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Disables the GPIO Pin Event interrupt
- *
- * This function will disable the GPIO Input(Row or Col) Pin Event interrupt
- *
- * @param[in] device_slot Defines slot where RF-TCA8418-MVK module is plugged into MB-PRO-MVK motherboard
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- ********************************************************************************************************************************/
- void Disable_TCA8418_GP_Input_Event_Interrupt ( unsigned char I2C_slave_address)
- {
- unsigned char TCA8418_Configuration = 0X00 ;
-
- TCA8418_Configuration = Read_TCA8418_Register (TCA8418_CONFIGURATION_REGISTER,I2C_slave_address);
- TCA8418_Configuration = TCA8418_Configuration & 0XFD ;
-
- Write_TCA8418_Register (TCA8418_CONFIGURATION_REGISTER, TCA8418_Configuration, I2C_slave_address);
- }
- /********************************************************************************************************************************
- * Set_TCA8418_Keylock_Timer_Value
- ********************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Sets the Keylock Timer for delay "fill this in"
- *
- * This function will set the Keylock Timer Value for the Delay time between Key Unlock Press #1 and Key Unlock Press #2
- *
- * @param[in] keypad_lock_timer_value Sets time delay "fill this in Later"
- * @param[in] device_slot Defines slot where RF-TCA8418-MVK module is plugged into MB-PRO-MVK motherboard
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- ********************************************************************************************************************************/
- void Set_TCA8418_Keylock_Timer_Value (unsigned char keypad_lock_timer_value,
- unsigned char I2C_slave_address)
- {
- unsigned char TCA8418_Keypad_Timer = 0x00; // Zero out global variable
-
- TCA8418_Keypad_Timer = Read_TCA8418_Register (TCA8418_KEYPAD_LOCK_TIMER_REGISTER, I2C_slave_address);
-
- TCA8418_Keypad_Timer = (keypad_lock_timer_value & 0XF8) | keypad_lock_timer_value;
-
- Write_TCA8418_Register (TCA8418_KEYPAD_LOCK_TIMER_REGISTER, TCA8418_Keypad_Timer, I2C_slave_address);
- }
- /********************************************************************************************************************************
- * Get_TCA8418_Keylock_Timer_Value
- ********************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Gets the Keylock Timer for delay "fill this in"
- *
- * This function will get the Keylock Timer Value for the Delay time between Key Unlock Press #1 and Key Unlock Press #2
- *
- * @param[out] keypad_lock_timer_value Time delay "fill this in Later"
- * @param[in] device_slot Defines slot where RF-TCA8418-MVK module is plugged into MB-PRO-MVK motherboard
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- ********************************************************************************************************************************/
- void Get_TCA8418_Keylock_Timer_Value (unsigned char keypad_lock_timer_value,
- unsigned char I2C_slave_address)
- {
- unsigned char TCA8418_Keypad_Timer = 0x00; // Zero out global variable
-
- TCA8418_Keypad_Timer = Read_TCA8418_Register (TCA8418_KEYPAD_LOCK_TIMER_REGISTER,I2C_slave_address);
-
- keypad_lock_timer_value = TCA8418_Keypad_Timer & 0X07 ;
-
- }
- /********************************************************************************************************************************
- * Set_TCA8418_Keylock_Interrupt_Mask_Timer_Value
- ********************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Sets the Keylock Interrupt Mask Timer
- *
- * This function will set the Keylock Interrupt Mask Timer Value
- *
- * @param[in] keypad_lock_interrupt_mask_timer_value Mask timer delay "fill this in Later"
- * @param[in] device_slot Defines slot where RF-TCA8418-MVK module is plugged into MB-PRO-MVK motherboard
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- ********************************************************************************************************************************/
- void Set_TCA8418_Keylock_Interrupt_Mask_Timer_Value (unsigned char keypad_lock_interrupt_mask_timer_value,
- unsigned char I2C_slave_address)
- {
- unsigned char TCA8418_Keypad_Timer = 0x00; // Zero out global variable
-
- TCA8418_Keypad_Timer = Read_TCA8418_Register (TCA8418_KEYPAD_LOCK_TIMER_REGISTER, I2C_slave_address);
-
- TCA8418_Keypad_Timer = (TCA8418_Keypad_Timer & 0X07) | keypad_lock_interrupt_mask_timer_value;
- Write_TCA8418_Register (TCA8418_KEYPAD_LOCK_TIMER_REGISTER, TCA8418_Keypad_Timer,I2C_slave_address);
-
- }
- /********************************************************************************************************************************
- * Get_TCA8418_Keylock_Interrupt_Mask_Timer_Value
- ********************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Gets the Keylock Interrupt Mask Timer Value
- *
- * This function will get the Keylock Interrupt Mask Timer Value
- *
- * @param[out] keypad_lock_interrupt_mask_timer_value Mask timer delay "fill this in Later"
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- ********************************************************************************************************************************/
- void Get_TCA8418_Keylock_Interrupt_Mask_Timer_Value (unsigned char keypad_lock_interrupt_mask_timer_value,
- unsigned char I2C_slave_address)
- {
- unsigned char TCA8418_Keypad_Timer = 0x00;
-
- TCA8418_Keypad_Timer = Read_TCA8418_Register (TCA8418_KEYPAD_LOCK_TIMER_REGISTER, I2C_slave_address);
-
- keypad_lock_interrupt_mask_timer_value = TCA8418_Keypad_Timer & 0XF8 ;
-
- }
- /********************************************************************************************************************************
- * Set_TCA8418_Keylock_Unlock_Values
- ********************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Sets the Unlock Key Values for Key 1 and Key 2
- *
- * This function will set the Unlock Key Values for Key 1 and Key 2
- *
- * @param[in] key_1_unlock_value Key 1 unlock value
- * @param[in] key_2_unlock_value Key 2 unlock value
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- ********************************************************************************************************************************/
- void Set_TCA8418_Keylock_Unlock_Values (unsigned char key_1_unlock_value,
- unsigned char key_2_unlock_value,
- unsigned char I2C_slave_address)
- {
- unsigned char I2C_key_1_unlock_value = key_1_unlock_value;
- unsigned char I2C_key_2_unlock_value = key_2_unlock_value;
-
- Write_TCA8418_Register (TCA8418_UNLOCK_KEY_1_REGISTER, I2C_key_1_unlock_value, I2C_slave_address);
-
- Write_TCA8418_Register (TCA8418_UNLOCK_KEY_2_REGISTER, I2C_key_2_unlock_value, I2C_slave_address);
- }
- /********************************************************************************************************************************
- * Set_TCA8418_Keylock_Unlock_Values
- ********************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Gets the Unlock Key Values for Key 1 and Key 2
- *
- * This function will get the Unlock Key Values for Key 1 and Key 2
- *
- * @param[out] key_1_unlock_value Key 1 unlock value
- * @param[out] key_2_unlock_value Key 2 unlock value
- * @param[in] device_slot Defines slot where RF-TCA8418-MVK module is plugged into MB-PRO-MVK motherboard
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- ********************************************************************************************************************************/
- void Get_TCA8418_Keylock_Unlock_Values (unsigned char key_1_unlock_value,
- unsigned char key_2_unlock_value,
- unsigned char I2C_slave_address)
- {
- unsigned char return_status;
- unsigned char I2C_key_1_unlock_value = 0X00;
- unsigned char I2C_key_2_unlock_value = 0X00;
-
- I2C_key_1_unlock_value = Read_TCA8418_Register (TCA8418_UNLOCK_KEY_1_REGISTER, I2C_slave_address);
-
- I2C_key_2_unlock_value = Read_TCA8418_Register (TCA8418_UNLOCK_KEY_2_REGISTER, I2C_slave_address);
-
- key_1_unlock_value = I2C_key_1_unlock_value;
- key_2_unlock_value = I2C_key_2_unlock_value;
- }
- /**************************************************************************************************************************************************
- * Set_TCA8418_Keylock_State
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Set(Enable or Disable) the Key Lock state
- *
- * This function sets the state of the TC8418 Key Lock (Enable or Disable)
- *
- * @param[in] keylock_state Key Lock state can be set to ENABLE or DISABLE
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- void Set_TCA8418_Keylock_State(unsigned char keylock_state,
- unsigned char I2C_slave_address)
- {
-
- unsigned char TCA8418_Key_Lock_Event_Counter = 0x00; // Zero out global register
-
- TCA8418_Key_Lock_Event_Counter = Read_TCA8418_Register (TCA8418_KEY_LOCK_AND_EVENT_COUNTER_REGISTER,I2C_slave_address);
-
- TCA8418_Key_Lock_Event_Counter = (TCA8418_Key_Lock_Event_Counter & 0XCF) | keylock_state ;
- Write_TCA8418_Register (TCA8418_KEY_LOCK_AND_EVENT_COUNTER_REGISTER, TCA8418_Key_Lock_Event_Counter, I2C_slave_address);
- }
- /**************************************************************************************************************************************************
- * Enable_TCA8418_Keylock
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Enables the Key Lock state
- *
- * This function sets the state of the TC8418 Key Lock to ENABLE.
- *
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- void Enable_TCA8418_Keylock( unsigned char I2C_slave_address)
- {
- Set_TCA8418_Keylock_State(0X00, I2C_slave_address); // Enable Keylock Function
- }
- /**************************************************************************************************************************************************
- * Disable_TCA8418_Keylock
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Disables the Key Lock state
- *
- * This function sets the state of the TC8418 Key Lock to DISABLE.
- *
- * @param[in] device_slot Defines slot where RF-TCA8418-MVK module is plugged into MB-PRO-MVK motherboard
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- void Disable_TCA8418_Keylock(unsigned char I2C_slave_address)
- {
- Set_TCA8418_Keylock_State(0X30, I2C_slave_address); // Disable Keylock Function
- }
- /**************************************************************************************************************************************************
- * mvk_Get_TCA8418_Keylock_Status
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Get the Key Lock state (Enable or Disable)
- *
- * This function gets the state of the TC8418 Key Lock (Enable or Disable)
- *
- * @param[out] keypad_lock_status Key Lock state can be set to ENABLE or DISABLE
- * @param[in] device_slot Defines slot where RF-TCA8418-MVK module is plugged into MB-PRO-MVK motherboard
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- void Get_TCA8418_Keypad_Lock_Status(unsigned char keypad_lock_status,
- unsigned char I2C_slave_address)
- {
- unsigned char TCA8418_Key_Lock_Event_Counter = 0x00; // Zero out global variable
-
- TCA8418_Key_Lock_Event_Counter = Read_TCA8418_Register (TCA8418_KEY_LOCK_AND_EVENT_COUNTER_REGISTER, I2C_slave_address);
-
- keypad_lock_status = TCA8418_Key_Lock_Event_Counter;
- }
- /**************************************************************************************************************************************************
- * Set_TCA8418_Keypad_Lock_Interrupt
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Set(Enable or Disable) the Key Lock Interrupt
- *
- * This function sets the Key Lock Interrupt register to ENABLE or DISABLE
- *
- * @param[in] state Key Lock Interrupt state can be set to ENABLE or DISABLE
- * @param[in] device_slot Defines slot where RF-TCA8418-MVK module is plugged into MB-PRO-MVK motherboard
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- void Set_TCA8418_Keypad_Lock_Interrupt(unsigned char state, unsigned char I2C_slave_address)
- {
- unsigned char TCA8418_Configuration = 0x00; // Zero out global variable
-
- TCA8418_Configuration = Read_TCA8418_Register (TCA8418_CONFIGURATION_REGISTER,I2C_slave_address);
-
- TCA8418_Configuration = (TCA8418_Configuration & 0XFB)| state;
- Write_TCA8418_Register (TCA8418_CONFIGURATION_REGISTER, TCA8418_Configuration, I2C_slave_address);
- }
- /**************************************************************************************************************************************************
- * Enable_TCA8418_Keypad_Lock_Interrupt
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Enables the Key Lock Interrupt
- *
- * This function sets the Key Lock Interrupt register to ENABLE.
- *
- * @param[in] device_slot Defines slot where RF-TCA8418-MVK module is plugged into MB-PRO-MVK motherboard
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- void Enable_TCA8418_Keypad_Lock_Interrupt ( unsigned char I2C_slave_address)
- {
- Set_TCA8418_Keypad_Lock_Interrupt (0X04, I2C_slave_address);
- }
- /**************************************************************************************************************************************************
- * Disable_TCA8418_Keypad_Lock_Interrupt
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Disables the Key Lock Interrupt
- *
- * This function sets the Key Lock Interrupt register to DISABLE.
- *
- * @param[in] device_slot Defines slot where RF-TCA8418-MVK module is plugged into MB-PRO-MVK motherboard
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- void Disable_TCA8418_Keypad_Lock_Interrupt (unsigned char I2C_slave_address)
- {
- Set_TCA8418_Keypad_Lock_Interrupt (0X00, I2C_slave_address);
- }
- /**************************************************************************************************************************************************
- * Get_TCA8418_Interrupt_Status
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Get the TCA8418 Interrupt Status Register
- *
- * This function returns the TCA8418 interrupt status register containing individual bits (SET or CLEAR) for each interrupt in the status byte.
- *
- * @param[out] interrupt_status Contains individual bits for each current interrupt (SET or CLEAR)
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- unsigned char Get_TCA8418_Interrupt_Status ( unsigned char I2C_slave_address)
- {
- return Read_TCA8418_Register (TCA8418_INTERRUPT_STATUS_REGISTER, I2C_slave_address);
- }
- /**************************************************************************************************************************************************
- * Clear_TCA8418_Interrupt_Status
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Clears interrupts out of the TCA8418 Interrupt Register
- *
- * This function clears the indicated interrupts in the TCA8418.
- *
- * @param[in] interrupt_status Contains individual bits for each interrupt to clear
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- void Clear_TCA8418_Interrupt_Status (unsigned char interrupt_status,
- unsigned char I2C_slave_address)
- {
- unsigned char TCA8418_interrupt_status = interrupt_status;
-
- Write_TCA8418_Register (TCA8418_INTERRUPT_STATUS_REGISTER, TCA8418_interrupt_status, I2C_slave_address);
- }
- /**************************************************************************************************************************************************
- * Set_TCA8418_Debounce_State
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Sets the TCA8418 Debounce State
- *
- * This function sets the debounce state for the indicated row / columns
- *
- * @param[in] row7_row0_state Identifies the row settings
- * @param[in] col9_col0_state Identifies the column settings
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- void Set_TCA8418_Debounce_State (unsigned int row7_row0_state,
- unsigned int col9_col0_state,
- unsigned char I2C_slave_address)
- {
- unsigned char TCA8418_row_debounce_state = ~(unsigned char)row7_row0_state; // Bitwise inversion Register bit defined 0=Enabled, 1=Disabled
- unsigned char TCA8418_col7_col0_debounce_state = ~(unsigned char)col9_col0_state; // Bitwise inversion Register bit defined 0=Enabled, 1=Disabled
- unsigned char TCA8418_col9_col8_debounce_state = ~(unsigned char)(col9_col0_state >> 8); // Bitwise inversion Register bit defined 0=Enabled, 1=Disabled
- Write_TCA8418_Register (TCA8418_GPIO_DEBOUNCE_DISABLE_1_REGISTER, TCA8418_row_debounce_state, I2C_slave_address);
- Write_TCA8418_Register (TCA8418_GPIO_DEBOUNCE_DISABLE_2_REGISTER, TCA8418_col7_col0_debounce_state, I2C_slave_address);
-
- Write_TCA8418_Register (TCA8418_GPIO_DEBOUNCE_DISABLE_3_REGISTER, TCA8418_col9_col8_debounce_state, I2C_slave_address);
-
- }
- /**************************************************************************************************************************************************
- * Get_TCA8418_Debounce_State
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Gets the TCA8418 Debounce State
- *
- * This function returns the debounce state for the indicated row / columns
- *
- * @param[out] row7_row0_state Location to place the row settings
- * @param[out] col9_col0_state Location to place the column settings
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- void Get_TCA8418_Debounce_State (unsigned int row7_row0_state,
- unsigned int col9_col0_state,
- unsigned char I2C_slave_address)
- {
- unsigned char TCA8418_row_debounce_state;
- unsigned char TCA8418_col7_col0_debounce_state;
- unsigned char TCA8418_col9_col8_debounce_state;
-
- TCA8418_row_debounce_state = Read_TCA8418_Register (TCA8418_GPIO_DEBOUNCE_DISABLE_1_REGISTER,I2C_slave_address);
-
- TCA8418_col7_col0_debounce_state = Read_TCA8418_Register (TCA8418_GPIO_DEBOUNCE_DISABLE_2_REGISTER,I2C_slave_address);
-
- TCA8418_col9_col8_debounce_state = Read_TCA8418_Register (TCA8418_GPIO_DEBOUNCE_DISABLE_3_REGISTER,I2C_slave_address);
-
- row7_row0_state = ~TCA8418_row_debounce_state; // Bitwise inversion Register bit defined 0=Enabled, 1=Disabled
- col9_col0_state = ~ ( ((unsigned int)TCA8418_col9_col8_debounce_state << 8) | // Bitwise inversion Register bit defined 0=Enabled, 1=Disabled
- (unsigned int)TCA8418_col7_col0_debounce_state);
- }
- /**************************************************************************************************************************************************
- * Set_TCA8418_GPIO_Pullup_State
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Sets the TCA8418 GPIO pullup registers
- *
- * This function sets the GPIO pullup state for the indicated row / columns
- *
- * @param[in] row7_row0_state Identifies the row settings
- * @param[in] col9_col0_state Identifies the column settings
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- void Set_TCA8418_GPIO_Pullup_State (unsigned int row7_row0_state,
- unsigned int col9_col0_state,
- unsigned char I2C_slave_address)
- {
- unsigned char TCA8418_row_pullup_state = ~(unsigned char)row7_row0_state; // Bitwise inversion Register bit defined 0=Enabled, 1=Disabled
- unsigned char TCA8418_col7_col0_pullup_state = ~(unsigned char)col9_col0_state; // Bitwise inversion Register bit defined 0=Enabled, 1=Disabled
- unsigned char TCA8418_col9_col8_pullup_state = ~(unsigned char)(col9_col0_state >> 8); // Bitwise inversion Register bit defined 0=Enabled, 1=Disabled
-
- Write_TCA8418_Register (TCA8418_GPIO_PULLUP_1_REGISTER, TCA8418_row_pullup_state, I2C_slave_address);
-
- Write_TCA8418_Register (TCA8418_GPIO_PULLUP_2_REGISTER, TCA8418_col7_col0_pullup_state, I2C_slave_address);
-
- Write_TCA8418_Register (TCA8418_GPIO_PULLUP_3_REGISTER, TCA8418_col9_col8_pullup_state, I2C_slave_address);
- }
- /**************************************************************************************************************************************************
- * Get_TCA8418_GPIO_Pullup_State
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Gets the TCA8418 GPIO pullup registers
- *
- * This function returns the GPIO pullup state for the indicated row / columns
- *
- * @param[out] row7_row0_state Location to place the row settings
- * @param[out] col9_col0_state Location to place the column settings
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- void Get_TCA8418_GPIO_Pullup_State (unsigned int row7_row0_state,
- unsigned int col9_col0_state,
- unsigned char I2C_slave_address)
- {
- unsigned char TCA8418_row_pullup_state;
- unsigned char TCA8418_col7_col0_pullup_state;
- unsigned char TCA8418_col9_col8_pullup_state;
-
- TCA8418_row_pullup_state = Read_TCA8418_Register (TCA8418_GPIO_PULLUP_1_REGISTER, I2C_slave_address);
-
- TCA8418_col7_col0_pullup_state = Read_TCA8418_Register (TCA8418_GPIO_PULLUP_2_REGISTER,I2C_slave_address);
-
- TCA8418_col9_col8_pullup_state = Read_TCA8418_Register (TCA8418_GPIO_PULLUP_3_REGISTER,I2C_slave_address);
-
- row7_row0_state = ~TCA8418_row_pullup_state; // Bitwise inversion Register bit defined 0=Enabled, 1=Disabled
- col9_col0_state = ~ ( ((unsigned int)TCA8418_col9_col8_pullup_state << 8) | // Bitwise inversion Register bit defined 0=Enabled, 1=Disabled
- (unsigned int)TCA8418_col7_col0_pullup_state);
- }
- /**************************************************************************************************************************************************
- * Get_TCA8418_GPIO_Interrupt_Status
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Get the TCA8418 GPIO Interrupt Status Register
- *
- * This function returns the TCA8418 GPIO interrupt status register containing individual bits (SET or CLEAR) for each GPIO interrupt in the
- * status bytes.
- *
- * @param[out] GPIO_interrupt_status_1 Contains individual bits for each current GPIO interrupt (SET or CLEAR)
- * @param[out] GPIO_interrupt_status_2 Contains individual bits for each current GPIO interrupt (SET or CLEAR)
- * @param[out] GPIO_interrupt_status_3 Contains individual bits for each current GPIO interrupt (SET or CLEAR)
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- void Get_TCA8418_GPIO_Interrupt_Status (unsigned char GPIO_interrupt_status_1,
- unsigned char GPIO_interrupt_status_2,
- unsigned char GPIO_interrupt_status_3,
- unsigned char I2C_slave_address)
- {
- unsigned char TCA8418_GPIO_interrupt_status_1 = 0x00;
- unsigned char TCA8418_GPIO_interrupt_status_2 = 0x00;
- unsigned char TCA8418_GPIO_interrupt_status_3 = 0x00;
-
- TCA8418_GPIO_interrupt_status_1 = Read_TCA8418_Register (TCA8418_KEYSCAN_GPIO_FUNCTION_1_REGISTER, I2C_slave_address);
- TCA8418_GPIO_interrupt_status_2 = Read_TCA8418_Register (TCA8418_KEYSCAN_GPIO_FUNCTION_2_REGISTER, I2C_slave_address);
- TCA8418_GPIO_interrupt_status_3 = Read_TCA8418_Register (TCA8418_KEYSCAN_GPIO_FUNCTION_3_REGISTER, I2C_slave_address);
-
- GPIO_interrupt_status_1 = TCA8418_GPIO_interrupt_status_1;
- GPIO_interrupt_status_2 = TCA8418_GPIO_interrupt_status_2;
- GPIO_interrupt_status_3 = TCA8418_GPIO_interrupt_status_3;
-
- }
- /**************************************************************************************************************************************************
- * Get_TCA8418_GPIO_Data_Status
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Get the TCA8418 GPIO Data Status
- *
- * This function returns the TCA8418 GPIO datt bits for each GPIO pin in the TCA8418.
- *
- * @param[out] GPIO_data_status_1 Contains individual bits with the data from each GPIO
- * @param[out] GPIO_data_status_2 Contains individual bits with the data from each GPIO
- * @param[out] GPIO_data_status_3 Contains individual bits with the data from each GPIO
- * @param[in] device_slot Defines slot where RF-TCA8418-MVK module is plugged into MB-PRO-MVK motherboard
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- void Get_TCA8418_GPIO_Data_Status (unsigned char GPIO_data_status_1,
- unsigned char GPIO_data_status_2,
- unsigned char GPIO_data_status_3,
- unsigned char I2C_slave_address)
- {
- unsigned char TCA8418_GPIO_data_status_1 = 0x00;
- unsigned char TCA8418_GPIO_data_status_2 = 0x00;
- unsigned char TCA8418_GPIO_data_status_3 = 0x00;
-
- TCA8418_GPIO_data_status_1 = Read_TCA8418_Register (TCA8418_GPIO_DATA_STATUS_1_REGISTER, I2C_slave_address);
-
- TCA8418_GPIO_data_status_2 = Read_TCA8418_Register (TCA8418_GPIO_DATA_STATUS_2_REGISTER, I2C_slave_address);
-
- TCA8418_GPIO_data_status_3 = Read_TCA8418_Register (TCA8418_GPIO_DATA_STATUS_3_REGISTER, I2C_slave_address);
-
- GPIO_data_status_1 = TCA8418_GPIO_data_status_1;
- GPIO_data_status_2 = TCA8418_GPIO_data_status_2;
- GPIO_data_status_3 = TCA8418_GPIO_data_status_3;
- }
- /**************************************************************************************************************************************************
- * Process_TCA8418_Interrupt
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Public
- *
- * @brief Process TCA8418 Interrupt
- *
- * This function processes the various TCA8418 interrupts, including CTRL-ALT-DEL, KEY Lock, GPI events, Key buffer overflow, and general Key events
- *
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- void Process_TCA8418_Interrupt ( unsigned char I2C_slave_address)
- {
- unsigned char lock_status;
- unsigned char number_of_key_events_in_buffer;
- unsigned char interrupt_status = 0x00;
- volatile TCA8418_Interrupt_Status_register_type *TCA8418_Interrupt_Status_register = (TCA8418_Interrupt_Status_register_type*)&interrupt_status;
- Disable_TCA8418_Key_Event_Interrupt (I2C_slave_address); // Prevent TCA8418 from generating additional interrupts until current one is processed
-
- Get_TCA8418_Interrupt_Status (I2C_slave_address); // Find out what type of action is required by the TCA8418
-
-
- if (TCA8418_Interrupt_Status_register->Key_Event_Interrupt_Flag)
- {
- Move_Key_Events_From_TCA8418_FIFO_To_Buffer (TCA8418_Key_Event_Buffer, // Globally allocated buffer array in TCA8418_Key_Scan.c
- TCA8418_KEY_EVENT_BUFFER_SIZE,
- number_of_key_events_in_buffer,
- I2C_slave_address);
-
-
- // Prints Key Press/Realease to terminal
- // Replace Print_Key_Event below below with call to process key events for your specific embedded system
- TCA8418_Print_Key_Event (TCA8418_Key_Event_Buffer,
- number_of_key_events_in_buffer,
- I2C_slave_address);
-
- // Data is available to be packetized, if desired by the main program
- TCA8418_Key_Events_In_Buffer_Size = number_of_key_events_in_buffer; // Provides user an indication of the number of events currently in the buffer
- }
-
-
- Clear_TCA8418_Interrupt_Status (interrupt_status, I2C_slave_address);
-
- Enable_TCA8418_Key_Event_Interrupt (I2C_slave_address);
- }
- /**************************************************************************************************************************************************
- * TCA8418_Print_Key_Event
- **************************************************************************************************************************************************/
- /*!
- * @ingroup TCA8418_Functions_Private
- *
- * @brief Prints the key event buffer out the UART Print buffer
- *
- * This function prints debug messages for all key events present in the buffer.
- *
- * @param[in] TCA8418_key_event_buffer Pointer to the key event buffer containing the key press events
- * @param[in] number_of_key_events_in_buffer Number of characters in the event buffer
- * @param[in] I2C_slave_address TCA8418 I2C slave address
- *
- * @return I2C_OPERATION_SUCCESSFUL Success
- * @return I2C_WRITE_FAILED_NACK Failure as TCA8418 NAK a transmission on I2C
- **************************************************************************************************************************************************/
- //void TCA8418_Print_Key_Event (unsigned char TCA8418_key_event_buffer,
- // unsigned char number_of_key_events_in_buffer,
- // unsigned char I2C_slave_address)
- //{
- // unsigned char number_of_key_events = number_of_key_events_in_buffer;
- // unsigned char buffer_index= 0;
- // unsigned char keypad_locked;
- // unsigned char key;
- // unsigned char key_state;
- //
- // Get_TCA8418_Keypad_Lock_Status(&keypad_locked, device_slot, I2C_slave_address);
- //
- // while(number_of_key_events > 0)
- // {
- // TCA8418_Key_Event = TCA8418_key_event_buffer[buffer_index];
- // key = TCA8418_Key_Event_register->Key_Event;
- // key_state = TCA8418_Key_Event_register->Key_Press_State;
- //
- // if (!keypad_locked)
- // {
- // switch(key)
- // {
- // case SWITCH_1:
- // mvk_UART_Debug_PrintF_Flush ("7", 1);
- // break;
- //
- // case SWITCH_2:
- // mvk_UART_Debug_PrintF_Flush ("8", 1);
- // break;
- //
- // case SWITCH_3:
- // mvk_UART_Debug_PrintF_Flush ("9", 1);
- // break;
- //
- // case SWITCH_4:
- // mvk_UART_Debug_PrintF_Flush ("4", 1);
- // break;
- //
- // case SWITCH_5:
- // mvk_UART_Debug_PrintF_Flush ("5", 1);
- // break;
- //
- // case SWITCH_6:
- // mvk_UART_Debug_PrintF_Flush ("6", 1);
- // break;
- //
- // case SWITCH_7:
- // mvk_UART_Debug_PrintF_Flush ("1", 1);
- // break;
- //
- // case SWITCH_8:
- // mvk_UART_Debug_PrintF_Flush ("2", 1);
- // break;
- //
- // case SWITCH_9:
- // mvk_UART_Debug_PrintF_Flush ("3", 1);
- // break;
- //
- // case SHIFT_SWITCH:
- // mvk_UART_Debug_PrintF_Flush ("SHIFT", 5);
- // break;
- //
- // case SWITCH_0:
- // mvk_UART_Debug_PrintF_Flush ("0", 1);
- // break;
- //
- // case ENTER_SWITCH: // ENTER_SWITCH used as a special Key to initiate keypad lock
- //
- // if(Is_TCA8418_Keylock_Available())
- // {
- // if (!keypad_locked) // Remove if ENTER key is not used as Lock Keypad Key Event
- // {
- // Enable_TCA8418_Keylock(I2C_slave_address);
- // Enable_TCA8418_Keypad_Lock_Interrupt ( I2C_slave_address);
- // }
- // }
- // else
- // {
- // mvk_UART_Debug_PrintF_Flush ("ENTER", 5);
- // }
- // break;
- //
- // case NAVIGATION_UP:
- // mvk_UART_Debug_PrintF_Flush ("NAV_UP", 6);
- // break;
- //
- // case NAVIGATION_DOWN:
- // mvk_UART_Debug_PrintF_Flush ("NAV_DOWN", 8);
- // break;
- //
- // case NAVIGATION_RIGHT:
- // mvk_UART_Debug_PrintF_Flush ("NAV_RIGHT", 9);
- // break;
- //
- // case NAVIGATION_LEFT:
- // mvk_UART_Debug_PrintF_Flush ("NAV_LEFT", 8);
- // break;
- //
- // case NAVIGATION_SELECT:
- // mvk_UART_Debug_PrintF_Flush ("NAV_SELECT", 10);
- // break;
- //
- // default:
- // mvk_UART_Debug_PrintF_Flush ("UNDEFINED_KEY_ERROR", 19);
- // break;
- // }
- // }// end of if (!keypad_locked)
- //
- // // Get current state of keypad locked, it could have changed if ENTER key processed above
- // Get_TCA8418_Keypad_Lock_Status(&keypad_locked, device_slot, I2C_slave_address);
- //
- // if (!keypad_locked)
- // {
- // switch(key_state)
- // {
- // case KEY_RELEASED:
- // mvk_UART_Debug_PrintF_Flush ("_KEY_RELEASED \n\r", 16);
- // break;
- //
- // case KEY_PRESSED:
- // mvk_UART_Debug_PrintF_Flush ("_KEY_PRESSED \n\r", 15);
- // break;
- // default:
- // mvk_UART_Debug_PrintF_Flush ("_UNDEFINED_KEY_STATE_ERROR \n\r", 29);
- // break;
- // }
- // }// end of if (!keypad_locked)
- //
- // ++buffer_index;
- // --number_of_key_events;
- //
- // } // End While (Key_Events > 0)
- //}
- /*************************************************************************************************************************************************/
- /* End of PUBLIC section */
- /* */
- /*! \endcond */
- /*************************************************************************************************************************************************/
复制代码
LCD驱动:
- #include "msp430fr5969.h"
- #include "SPI.h"
- #include "IO_Define.h"
- #include "LCD.h"
- #include "zifu.h"
- #include "delay.h"
- void HDReset()
- {
- //LCD_CS_0;
- LCD_RSTB_0;
- TimerDelay_ms(20);
- LCD_RSTB_1;
- TimerDelay_ms(40);
- //LCD_CS_1;
- }
- void Init_ST7567()
- {
- LCD_AO_0; //发指令
- //SPI_SELECT_LCD; //SELECT LCD
- LCD_CS_0;
- HDReset();
- TimerDelay_ms(100);
-
- UCB0TXBUF = 0xe2; //SOFT RESET//寄存器复位
- TimerDelay_us(64);
- UCB0TXBUF = 0xaf; //0xaf显示器开
- TimerDelay_us(64);
- UCB0TXBUF = 0x2f; //0x2f升压电路,电压管理电路,
- TimerDelay_us(64);
- UCB0TXBUF = 0x25; //0x20-0x27为V5电压内部电阻调整设置
- TimerDelay_us(64);
- UCB0TXBUF = 0x81; // SET EV 调对比度
- TimerDelay_us(64);
- UCB0TXBUF = 0x1F; //0x01-0x3f电量寄存器设置模式
- TimerDelay_us(64);
- UCB0TXBUF = 0xa0; //0xa0为Segment正向,0xa1 为Segment反向
- TimerDelay_us(64);
- UCB0TXBUF = 0xc8; //0xc0正向扫描,0xc8反射扫描
- TimerDelay_us(64);
- UCB0TXBUF = 0xa6; // //0xa6正向显示,0xa7反向显示
- TimerDelay_us(64);
- UCB0TXBUF = 0xa4; // //0xa4正常显示,0xa5全屏点亮
- TimerDelay_us(64);
- UCB0TXBUF = 0xf8; // //背压比设置
- TimerDelay_us(64);
- UCB0TXBUF = 0x00; //00--10
- TimerDelay_us(64);
- LCD_AO_0;
- // Stop_SPI();
- //LCD_CS_1;
- }
- /*-------------------------------------------
- LCD_set_XY: 设置LCD坐标函数
- 输入参数:X:0-128(column) Y:0-8(page)
- 编写日期:20140315
- ---------------------------------------------*/
- void LCD_set_XY(unsigned int X, unsigned char Y)
- {
- unsigned char temp1 = 0,temp2 = 0;
- // Star_SPI();
- LCD_CS_0;
- LCD_AO_0;
- UCB0TXBUF = 0xb0+Y; //设置page(页)地址
- TimerDelay_us(64);
- temp1 =( X & 0XF0)>>4; //高四位
- temp2 = X & 0X0F; //低四位
- UCB0TXBUF = 0x10|temp1; //设置column(列)地址高4位 (共有131列)
- TimerDelay_us(64);
- UCB0TXBUF = temp2; //设置column(列)地址低4位
- TimerDelay_us(64);
- LCD_AO_1;
- }
- /*-------------------------------------------
- Clear_Arrow: 清除箭头
- 输入参数:X:0-128(column) Y:0-8(page)
- 编写日期:20140315
- ---------------------------------------------*/
- void Clear_Arrow(unsigned char column,unsigned char page)
- {
- LCD_write_word(column, page , 34);
- }
- /*-------------------------------------------
- Clear_Region: 清除区域
- 输入参数:column1:起始点横坐标
- page1:起始点纵坐标
- column2:终点横坐标
- page2:终点纵坐标
- xx : 填充内容
- 编写日期:20140315
- ---------------------------------------------*/
- void Clear_Region(unsigned char column1,unsigned char page1,unsigned char column2,unsigned char page2,unsigned char xx)
- {
- unsigned char i,j;
- LCD_CS_0;
- for(i=page1;i<page2;i++)
- {
- LCD_AO_0;
- UCB0TXBUF = 0xb0+i; //设置page(页)地址 (共有8页)
- TimerDelay_us(64);
- UCB0TXBUF = 0x10; //设置column(列)地址高4位 (共有131列)
- TimerDelay_us(64);
- UCB0TXBUF = 0x00; //设置column(列)地址低4位
- TimerDelay_us(64);
- for(j=column1;j<column2;j++)
- {
- LCD_AO_1;
- UCB0TXBUF = xx;
- TimerDelay_us(64);
- }
- }
- LCD_CS_1;
- }
- /*---------------------------------------------
- LCD_write_zimu: 显示6(宽)*12(高)点阵列数字字母符号等半角类
- 输入参数:c:显示的字符;
- 编写日期:20140315
- -----------------------------------------------*/
- void LCD_write_zimu(unsigned char column, unsigned char page,unsigned char c) //row:列 page:页 dd:字符
- {
- unsigned char i;
-
- LCD_set_XY(column, page);// 列,页
- for(i=0; i<8;i++)
- {
- UCB0TXBUF = zimu[c*16+i];
- TimerDelay_us(64);
- }
-
- LCD_set_XY(column, page+1);// 列,页
- for(i=8; i<16;i++)
- {
- UCB0TXBUF = zimu[c*16+i];
- TimerDelay_us(64);
- }
- LCD_CS_1;
- }
- /*---------------------------------------------
- LCD_write_shu_6_8: 显示6(宽)*8(高)点阵列数字字母符号等半角类
- 输入参数:c:显示的字符;
- 编写日期:20140315
- -----------------------------------------------*/
- void LCD_write_shu_6_8(unsigned char column, unsigned char page,unsigned char c) //row:列 page:页 dd:字符
- {
- unsigned char i;
-
- LCD_set_XY(column, page);// 列,页
- for(i=0; i<6;i++)
- {
- UCB0TXBUF = shuzi_6_8[c*6+i];
- TimerDelay_us(64);
- }
- LCD_CS_1;
- }
- /*---------------------------------------------
- LCD_write_shu_6_8: 显示6(宽)*8(高)点阵列数字字母符号等半角类,支持反向显示
- 输入参数:c:显示的字符;
- 编写日期:20140315
- -----------------------------------------------*/
- void LCD_write_shu_6_8_opp(unsigned char column, unsigned char page,unsigned char c,unsigned char opposite) //row:列 page:页 dd:字符
- {
- unsigned char i;
-
- LCD_set_XY(column, page);// 列,页
- if(opposite == 0)
- {
- for(i=0; i<6;i++)
- {
- UCB0TXBUF = shuzi_6_8[c*6+i];
- TimerDelay_us(64);
- }
- }
- else if(opposite == 1)
- {
- for(i=0; i<6;i++)
- {
- UCB0TXBUF = ~shuzi_6_8[c*6+i];
- TimerDelay_us(64);
- }
- }
- LCD_CS_1;
-
- }
- /*---------------------------------------------
- LCD_write_shu_6_16: 显示6(宽)*16(高)点阵列数字字母符号等半角类
- 输入参数:c:显示的字符;
- 编写日期:20140315
- -----------------------------------------------*/
- void LCD_write_shu_6_16(unsigned char column, unsigned char page,unsigned char c) //row:列 page:页 dd:字符
- {
- unsigned char i;
-
- LCD_set_XY(column, page);// 列,页
- for(i=0; i<6;i++)
- {
- UCB0TXBUF = shuzi_6_16[c*12+i];
- TimerDelay_us(64);
- }
-
- LCD_set_XY(column, page+1);// 列,页
- for(i=6; i<12;i++)
- {
- UCB0TXBUF = shuzi_6_16[c*12+i];
- TimerDelay_us(64);
- }
- LCD_CS_1;
- }
- /*---------------------------------------------
- LCD_write_shu_13_24: 显示13(宽)*24(高)点阵列数字字母符号等半角类
- 输入参数:c:显示的字符;
- 编写日期:20140315
- -----------------------------------------------*/
- void LCD_write_shu_13_24(unsigned char column, unsigned char page,unsigned char c) //row:列 page:页 dd:字符
- {
- unsigned char i;
-
- LCD_set_XY(column, page);// 列,页
- for(i=0; i<13;i++)
- {
- UCB0TXBUF = shuzi_13_24[c*39+i];
- TimerDelay_us(64);
- }
-
- LCD_set_XY(column, page+1);// 列,页
- for(i=13; i<26;i++)
- {
- UCB0TXBUF = shuzi_13_24[c*39+i];
- TimerDelay_us(64);
- }
- LCD_set_XY(column, page+2);// 列,页
- for(i=26; i<39;i++)
- {
- UCB0TXBUF = shuzi_13_24[c*39+i];
- TimerDelay_us(64);
- }
- LCD_CS_1;
- }
- /*---------------------------------------------
- LCD_write_shu_digit: 显示9(宽)*16(高)点阵列数字字母符号等半角类
- 输入参数:c:显示的字符;
- 编写日期:20140315
- -----------------------------------------------*/
- void LCD_write_shu_digit(unsigned char column, unsigned char page,unsigned char c) //row:列 page:页 dd:字符
- {
- unsigned char i;
-
- LCD_set_XY(column, page);// 列,页
- for(i=0; i<9;i++)
- {
- UCB0TXBUF = shuzi[c*18+i];
- TimerDelay_us(64);
- }
-
- LCD_set_XY(column, page+1);// 列,页
- for(i=9; i<18;i++)
- {
- UCB0TXBUF = shuzi[c*18+i];
- TimerDelay_us(64);
- }
- LCD_CS_1;
- }
- /*---------------------------------------------
- LCD_write_word: 显示16(宽)*16(高)点阵列数字字母符号等半角类
- 输入参数:c:显示的汉字;
- 编写日期:20140315
- -----------------------------------------------*/
- void LCD_write_word(unsigned char column, unsigned char page,unsigned char c) //row:列 page:页 dd:字符
- {
- unsigned char i;
-
- LCD_set_XY(column, page);// 列,页
- for(i=0; i<16;i++)
- {
- UCB0TXBUF = word[c*32+i];
- TimerDelay_us(64);
- }
-
- LCD_set_XY(column, page+1);// 列,页
- for(i=16; i<32;i++)
- {
- UCB0TXBUF = word[c*32+i];
- TimerDelay_us(64);
- }
- LCD_CS_1;
- }
- /*---------------------------------------------
- 函数名:LCD_write_Icon_Signal 显示信号强度图标
- 输入参数:c 信号强度等级 1最弱 5最强
- 编写日期:20141017
- -----------------------------------------------*/
- void LCD_write_Icon_Signal(unsigned char c) //row:列 page:页 dd:字符
- {
- LCD_set_XY(0, 8); //天线图标
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- switch(c)
- {
- case 1:
- LCD_set_XY(10, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- break;
- case 2:
- LCD_set_XY(10, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- LCD_set_XY(12, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- break;
- case 3:
- LCD_set_XY(10, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- LCD_set_XY(12, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- LCD_set_XY(16, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- break;
- case 4:
- LCD_set_XY(10, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- LCD_set_XY(12, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- LCD_set_XY(16, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- LCD_set_XY(18, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- break;
- case 5:
- LCD_set_XY(10, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- LCD_set_XY(12, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- LCD_set_XY(16, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- LCD_set_XY(18, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- LCD_set_XY(20, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- break;
- default:
- LCD_set_XY(10, 8);
- UCB0TXBUF = 0x00;
- TimerDelay_us(64);
- LCD_set_XY(12, 8);
- UCB0TXBUF = 0x00;
- TimerDelay_us(64);
- LCD_set_XY(16, 8);
- UCB0TXBUF = 0x00;
- TimerDelay_us(64);
- LCD_set_XY(18, 8);
- UCB0TXBUF = 0x00;
- TimerDelay_us(64);
- LCD_set_XY(20, 8);
- UCB0TXBUF = 0x00;
- TimerDelay_us(64);
- break;
- }
- LCD_CS_1;
- }
- /*---------------------------------------------
- 函数名:LCD_write_Icon_DumpEnergy 显示剩余电量图标
- 输入参数:c 剩余电量等级 0 (无) 1(25%) 2(50%)3(75%)4(100%)
- 编写日期:20141017
- -----------------------------------------------*/
- void LCD_write_Icon_DumpEnergy(unsigned char c) //row:列 page:页 dd:字符
- {
- LCD_set_XY(116, 8); //电池框图标
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- switch(c)
- {
- case 1:
- LCD_set_XY(120, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- break;
- case 2:
- LCD_set_XY(120, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- LCD_set_XY(123, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- break;
- case 3:
- LCD_set_XY(120, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- LCD_set_XY(123, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- LCD_set_XY(127, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- break;
- case 4:
- LCD_set_XY(120, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- LCD_set_XY(123, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- LCD_set_XY(127, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- LCD_set_XY(125, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- break;
- default:
- LCD_set_XY(120, 8);
- UCB0TXBUF = 0x00;
- TimerDelay_us(64);
- LCD_set_XY(123, 8);
- UCB0TXBUF = 0x00;
- TimerDelay_us(64);
- LCD_set_XY(125, 8);
- UCB0TXBUF = 0x00;
- TimerDelay_us(64);
- LCD_set_XY(127, 8);
- UCB0TXBUF = 0x00;
- TimerDelay_us(64);
- break;
- }
- LCD_CS_1;
- }
- /*---------------------------------------------
- 函数名:LCD_write_Icon_Voice 显示声音图标
- 输入参数:c 指示有无声 0 (无声) 1(有声)
- 编写日期:20141017
- -----------------------------------------------*/
- void LCD_write_Icon_Voice(unsigned char c) //row:列 page:页 dd:字符
- {
- switch(c)
- {
- case 0:
- LCD_set_XY(74, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- LCD_set_XY(79, 8);
- TimerDelay_us(64);
- UCB0TXBUF = 0x01;
- break;
- case 1:
- LCD_set_XY(74, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- LCD_set_XY(79, 8);
- UCB0TXBUF = 0x00;
- TimerDelay_us(64);
- break;
- default:
- break;
- }
- LCD_CS_1;
- }
- /*---------------------------------------------
- 函数名:LCD_write_Icon_Alarm 显示闹铃图标
- 输入参数:c 指示有无闹铃 0 (无) 1(有)
- 编写日期:20141017
- -----------------------------------------------*/
- void LCD_write_Icon_Alarm(unsigned char c) //row:列 page:页 dd:字符
- {
- switch(c)
- {
- case 0:
- LCD_set_XY(87, 8);
- UCB0TXBUF = 0x00;
- TimerDelay_us(64);
- break;
- case 1:
- LCD_set_XY(87, 8);
- UCB0TXBUF = 0x01;
- TimerDelay_us(64);
- break;
- default:
- break;
- }
- LCD_CS_1;
- }
- /*---------------------------------------------
- 函数名:Clear_Screen 清屏
- 输入参数:xx 填充
- 编写日期:20141017
- -----------------------------------------------*/
- void Clear_Screen( unsigned char xx)
- {
- unsigned char i,j;
- LCD_CS_0;
- for(i=0;i<9;i++)
- {
- LCD_AO_0;
- UCB0TXBUF = 0xb0+i; //设置page(页)地址 (共有8页)
- TimerDelay_us(64);
- UCB0TXBUF = 0x10; //设置column(列)地址高4位 (共有131列)
- TimerDelay_us(64);
- UCB0TXBUF = 0x00; //设置column(列)地址低4位
- TimerDelay_us(64);
- for(j=0;j<128;j++)
- {
- LCD_AO_1;
- UCB0TXBUF = xx;
- TimerDelay_us(64);
- }
- }
- LCD_CS_1;
- }
- /*---------------------------------------------
- 函数名:LCD_Display_Temprature 显示温度
- 输入参数:xx 填充
- 编写日期:20141017
- -----------------------------------------------*/
- void LCD_Display_Temprature(unsigned char column, unsigned char page,unsigned int number)
- {
- unsigned int num_temp[5] = {0};
- unsigned int temp = 0;
- temp = number + number -27315;
-
- num_temp[0] = temp/10000;
- num_temp[1] = temp/1000%10;
- num_temp[2] = temp/100%10;
- num_temp[3] = temp/10%10;
- num_temp[4] = temp%10;
-
- if(num_temp[0] == 0)
- num_temp[0] = 12;
- if((num_temp[0] == 0) || (num_temp[1] == 0))
- num_temp[1] = 12;
-
- LCD_write_shu_13_24(column,page,num_temp[0]);
- LCD_write_shu_13_24(column+13,page,num_temp[1]);
- LCD_write_shu_13_24(column+26,page,num_temp[2]);
- LCD_write_shu_13_24(column+39,page,10);
- LCD_write_shu_13_24(column+52,page,num_temp[3]);
- LCD_write_shu_13_24(column+65,page,num_temp[4]);
- LCD_write_shu_13_24(column+80,page,11);
-
-
- // while(!(UCA1IFG&UCTXIFG));
- // UCA1TXBUF = num_temp[0] + '0';
- // while(!(UCA1IFG&UCTXIFG));
- // UCA1TXBUF = num_temp[1] + '0';
- // while(!(UCA1IFG&UCTXIFG));
- // UCA1TXBUF = num_temp[2] + '0';
- // while(!(UCA1IFG&UCTXIFG));
- // UCA1TXBUF = '.';
- // while(!(UCA1IFG&UCTXIFG));
- // UCA1TXBUF = num_temp[3] + '0';
- // while(!(UCA1IFG&UCTXIFG));
- // UCA1TXBUF = num_temp[4] + '0';
- // while(!(UCA1IFG&UCTXIFG));
- // UCA1TXBUF = '\n';
- }
- /*---------------------------------------------
- 函数名:LCD_Display_ECG 显示心电波形
- 输入参数:xx 填充
- 编写日期:20141017
- -----------------------------------------------*/
- void LCD_Display_ECG(unsigned char column, unsigned char page,unsigned int number)
- {
- unsigned int num_temp[5] = {0};
- unsigned int temp = 0;
-
- num_temp[0] = temp/10000;
- num_temp[1] = temp/1000%10;
- num_temp[2] = temp/100%10;
- num_temp[3] = temp/10%10;
- num_temp[4] = temp%10;
-
- if(num_temp[0] == 0)
- num_temp[0] = 12;
- if((num_temp[0] == 0) && (num_temp[1] == 0))
- num_temp[1] = 12;
-
- LCD_write_shu_13_24(column,page,num_temp[0]);
- LCD_write_shu_13_24(column+13,page,num_temp[1]);
- LCD_write_shu_13_24(column+26,page,num_temp[2]);
- LCD_write_shu_13_24(column+39,page,10);
- LCD_write_shu_13_24(column+52,page,num_temp[3]);
- LCD_write_shu_13_24(column+65,page,num_temp[4]);
- LCD_write_shu_13_24(column+80,page,11);
- }
- /*---------------------------------------------
- 函数名:LCD_Display_BloodPresure 显示血压
- 输入参数:xx 填充
- 编写日期:20141017
- -----------------------------------------------*/
- void LCD_Display_BloodPresure(unsigned char column, unsigned char page, unsigned int Hi_Presure, unsigned int Low_Presure)
- {
- unsigned char num_temp1[3] = {0};
- unsigned char num_temp2[3] = {0};
- //unsigned int temp = 0;
-
- num_temp1[0] = Hi_Presure/100%10;
- num_temp1[1] = Hi_Presure/10%10;
- num_temp1[2] = Hi_Presure%10;
-
- num_temp2[0] = Low_Presure/100%10;
- num_temp2[1] = Low_Presure/10%10;
- num_temp2[2] = Low_Presure%10;
-
- //消零
- if(num_temp1[0] == 0)
- num_temp1[0] = 12;
- if((num_temp1[0] == 0) && (num_temp1[1] == 0))
- num_temp1[1] = 12;
- if(num_temp2[0] == 0)
- num_temp2[0] = 12;
- if((num_temp2[0] == 0) && (num_temp2[1] == 0))
- num_temp2[1] = 12;
-
- LCD_write_shu_13_24(column,page,num_temp1[0]);
- LCD_write_shu_13_24(column+13,page,num_temp1[1]);
- LCD_write_shu_13_24(column+26,page,num_temp1[2]);
- LCD_write_shu_13_24(column,page+2,num_temp2[0]);
- LCD_write_shu_13_24(column+13,page+2,num_temp2[1]);
- LCD_write_shu_13_24(column+26,page+2,num_temp2[2]);
-
- }
复制代码
MLX90615驱动:
EEPROM驱动:
- #include <msp430.h>
- #include "I2C.h"
- #include "24C512.h"
- void AT24C512_Byte_Write(unsigned char Device_Address,unsigned int Address,unsigned char data)
- {
- Start();
- WriteByte(Device_Address);
- ReceiveAck();
- WriteByte((unsigned char)((Address&0xff00)>>8));
- ReceiveAck();
- WriteByte((unsigned char)(Address&0x00ff));
- ReceiveAck();
- WriteByte(data);
- ReceiveAck();
- Stop();
- }
- unsigned char AT24C512_Byte_Read(unsigned char Device_Address,unsigned int Address)
- {
- unsigned char TempData = 0;
- Start();
- WriteByte(Device_Address);
- ReceiveAck();
- WriteByte((unsigned char)((Address&0xff00)>>8));
- ReceiveAck();
- WriteByte((unsigned char)(Address&0x00ff));
- ReceiveAck();
- Start();
- WriteByte(Device_Address|0x01);
- ReceiveAck();
- TempData = ReadByte();
- TransferAckOrNack(1);
- Stop();
- //Delay_us(66);
- return(TempData);
- }
复制代码
调试:
|