1 /* 2 * bios.h 3 * 4 * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/ 5 * 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 14 * Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the 17 * distribution. 18 * 19 * Neither the name of Texas Instruments Incorporated nor the names of 20 * its contributors may be used to endorse or promote products derived 21 * from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 */ 35 36 //! \ingroup MODULBIOS 37 //! \file bios.h 38 //! \brief 39 40 #ifndef _V3_BIOS_H_ 41 #define _V3_BIOS_H_ 42 43 #include "hw_compiler_specific.h" 44 #include "hil_Structs.h" 45 46 //*********** Defines *********** 47 #define BIOS_LED_MODE 0 48 #define BIOS_LED_POWER 1 49 50 #define BIOS_RX_SIZE 258 51 #define BIOS_RX_QUEUS 4 52 #define BIOS_TX_SIZE 258 53 #define BIOS_TX_QUEUS 1 54 #define BIOS_TX_FLAGS 1 55 56 #define BIOS_RX_RDY 0x01 57 #define BIOS_RX_CRC_ERROR 0x02 58 #define BIOS_RX_SIZE_ERROR 0x04 59 #define BIOS_TX_TO_SEND 0x01 60 #define BIOS_TX_WAIT_ON_ACK 0x02 61 #define BIOS_TX_NO_SEND 0x04 62 #define BIOS_TX_BUSY 0x08 63 64 #define BIOS_TX_TIMEOUT 50 65 66 #define BIOS_TIMER_BREAK 0x01 67 #define BIOS_TIMER_COUNT 2 68 #define BIOS_TIMER_RX 0 69 #define BIOS_TIMER_TX 1 70 71 #define COM_CHANNEL 2 72 #define DEBUG_CHANNEL 0 73 74 //*********** Structure definitions *********** 75 //! \struct Contains received messages 76 typedef struct _BiosRxRecord_ 77 { 78 unsigned char *data[BIOS_RX_QUEUS]; 79 unsigned short *datas[BIOS_RX_QUEUS]; 80 unsigned short count[BIOS_RX_QUEUS]; 81 unsigned short size[BIOS_RX_QUEUS]; 82 unsigned short last_msg_call; 83 unsigned short crc[BIOS_RX_QUEUS]; 84 unsigned char active; 85 unsigned char last_cmd_typ; 86 unsigned char last_msg_id; 87 unsigned char state[BIOS_RX_QUEUS]; 88 } BiosRxRecord; 89 90 91 92 //! \struct Contains messages to be transmitted 93 typedef struct _BiosTxRecord_ 94 { 95 unsigned char active; 96 unsigned char cannel_to_send; 97 unsigned short send_counter[BIOS_TX_QUEUS]; 98 unsigned short ack_timeout[BIOS_TX_QUEUS]; 99 unsigned char state[BIOS_TX_QUEUS]; 100 unsigned short count[BIOS_TX_QUEUS]; 101 unsigned short datas[BIOS_TX_QUEUS][BIOS_TX_SIZE/sizeof(unsigned short)]; 102 unsigned char *data[BIOS_TX_QUEUS]; 103 unsigned short *ext_data; 104 unsigned short ext_size; 105 unsigned short ext_counter; 106 } BiosTxRecord; 107 108 // System events 109 typedef enum SYSTEM_EVENT_MSP 110 { 111 /// System event FET connection is lost 112 FET_CONNECTION_LOST = 0, 113 /// System event device connection is lost 114 DEVICE_CONNECTION_LOST, 115 /// System event FET restart needed 116 FET_RESTART_NEEDED, 117 /// System event device entered LPMx.5 118 DEVICE_IN_LPM5_MODE, 119 /// System event devices wakes up from LPMx.5 120 DEVICE_WAKEUP_LPM5_MODE, 121 /// System event - overcurrent detection on JTAG lines or VCC line 122 FET_OVERCURRENT, 123 /// System event - Timout occourt during FPGA DR/IR shift 124 FET_FPGA_TIMOUT, 125 } SystemEventMsp; 126 127 struct BIOS_RxError 128 { 129 unsigned short bios_rx_err_code_; 130 unsigned short *bios_rx_err_payload_; 131 unsigned short bios_rx_err_id_; 132 unsigned short bios_rx_err_set_; 133 }; 134 typedef struct BIOS_RxError BIOS_RxError_t; 135 136 //! \struct Global timer used for timeouts 137 struct _BiosGlobalTimer_ 138 { 139 unsigned short count; 140 unsigned char state; 141 }; 142 typedef struct _BiosGlobalTimer_ BiosGlobalTimer; 143 144 //*********** Function protoypes *********** 145 146 //! \brief System start up 147 void BIOS_InitSystem(void); 148 void BIOS_SuspendSystem(void); 149 void BIOS_ResumeSystem(void); 150 151 //! \brief setup receiver buffers 152 void BIOS_InitCom(void); 153 154 //! \brief switch LED on 155 //! \details only the LED control struc are manipulated. The 156 //! hardware are in timerB1Isr driven 157 //! \param[in] LED no 0 = BIOS_LED_MODE (red)\n 158 //! 1 = BIOS_LED_POWER (green) 159 //! \return always 0 160 short BIOS_LedOn(unsigned char no); 161 162 //! \brief switch LED off 163 //! \details only the LED control struc are manipulated. The 164 //! hardware are in timerB1Isr driven 165 //! \param[in] no 0 = BIOS_LED_MODE (red)\n 166 //! 1 = BIOS_LED_POWER (green) 167 //! \return always 0 168 short BIOS_LedOff(unsigned char no); 169 170 //! \brief LED blink continuous 171 //! \param[in] no 0 = BIOS_LED_MODE (red)\n 172 //! 1 = BIOS_LED_POWER (green) 173 //! \param[in] time (*20ms) 174 //! \return always 0 175 short BIOS_LedBlink(unsigned char no,unsigned short time); 176 177 //! \brief LED flashes for a time 178 //! \param[in] no 0 = BIOS_LED_MODE (red)\n 179 //! 1 = BIOS_LED_POWER (green) 180 //! \param[in] time (*20ms) 181 //! \return always 0 182 //! \details if the LED is on, the LED goes off for "time" 183 //! if the LED is off, the LED goes on for "time" 184 short BIOS_LedFlash(unsigned char no,unsigned short time); 185 186 //! \brief LEDs blink alternated 187 //! \param[in] time (*20ms) 188 //! \return always 0 189 //! \details both LED are alternated on. 190 short BIOS_LedAlternate(unsigned short time); 191 192 //! \brief fatal error 193 //! \details LED are alternated, function never return 194 void BIOS_GlobalError(void); 195 196 //! \brief clear RX hard and software buffer 197 void BIOS_UsbRxClear(void); 198 199 //! \brief trigger a error message 200 //! \details trigger a error message and clear the RX hard and software buffers 201 void BIOS_UsbRxError(unsigned short code); 202 203 void BIOS_UsbTxClear(void); 204 //! \brief clears the TX software buffer 205 void BIOS_UsbTxError(void); 206 207 //! \brief finsh record to send 208 void BIOS_PrepareTx(unsigned int size); 209 210 //! \brief Stop RX 211 //! \details set CTS to TUSB and break RX timeout timer 212 void BIOS_SetCts(); 213 214 //! \brief release (restart) RX 215 //! \details reset CTS to TUSB and RX timeout timer running 216 void BIOS_ResetCts(); 217 218 //! \brief trigger sending of TX buffer 219 //! \details to send the first char we set UTXIFG, followed char loaded by 220 //! true TX buffer empty interrupt 221 void BIOS_StartTx(void); 222 short BIOS_UsbRxData(void); 223 224 unsigned long Bios_getDcdc_signature(); 225 unsigned long Bios_getHal_signature(); 226 unsigned long Bios_getHil_signature(); 227 unsigned long Bios_getCom_signature(); 228 229 unsigned long Bios_getHal_intvec(); 230 unsigned short Bios_getHil_intvec(); 231 unsigned long Bios_getDcdc_intvec(); 232 unsigned long Bios_getCom_intvec(); 233 234 unsigned short Bios_getCore_version(); 235 unsigned short Bios_getTool_id(); 236 unsigned short Bios_getInfo_hw_0(); 237 unsigned short Bios_getInfo_hw_1(); 238 239 short BIOS_IsUsbRxError(); 240 BIOS_RxError_t BIOS_getRxError(); 241 void BIOS_ClearUsbRxError(); 242 243 extern volatile BiosRxRecord bios_rx_record_; 244 extern volatile BiosTxRecord bios_tx_record_; 245 extern volatile BiosGlobalTimer bios_global_timer_[BIOS_TIMER_COUNT]; 246 extern char bios_wb_control_; 247 #endif 248