1 /**
2 * \ingroup MODULBIOS
3 *
4 * \file bios.h
5 *
6 * \brief <FILEBRIEF>
7 *
8 */
9 /*
10  * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
11  *
12  *
13  *  Redistribution and use in source and binary forms, with or without
14  *  modification, are permitted provided that the following conditions
15  *  are met:
16  *
17  *    Redistributions of source code must retain the above copyright
18  *    notice, this list of conditions and the following disclaimer.
19  *
20  *    Redistributions in binary form must reproduce the above copyright
21  *    notice, this list of conditions and the following disclaimer in the
22  *    documentation and/or other materials provided with the
23  *    distribution.
24  *
25  *    Neither the name of Texas Instruments Incorporated nor the names of
26  *    its contributors may be used to endorse or promote products derived
27  *    from this software without specific prior written permission.
28  *
29  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  */
41 
42 #ifndef _V3_BIOS_H_
43 #define _V3_BIOS_H_
44 
45 #include "hw_compiler_specific.h"
46 
47 extern void biosInitSystem (void);
48 extern void biosInitCom (unsigned long baudrate);
49 extern void biosSetWdt(unsigned char time);
50 extern void  biosmainLoop(void);
51 extern void biosUsbRxClear(void);
52 extern void biosUsbRxError(unsigned short code);
53 extern void biosUsbTxError(void);
54 extern void biosPrepareTx(unsigned int size);
55 extern void biosStartTx(void);
56 extern short biosLedOn(unsigned char no);
57 extern short biosLedOff(unsigned char no);
58 extern short biosLedBlink(unsigned char no,unsigned short time);
59 extern short biosLedFlash(unsigned char no,unsigned short time);
60 extern short biosLedAlternate(unsigned short time);
61 extern short biosHalInterfaceInit(void);
62 extern short biosHalInterfaceClear(void);
63 
64 
65 
66 #define BIOS_LED_MODE  0
67 #define BIOS_LED_POWER 1
68 
69 #define BIOS_RX_SIZE 258
70 #define BIOS_RX_QUEUS 2
71 #define BIOS_TX_SIZE 258
72 #define BIOS_TX_QUEUS 1
73 #define BIOS_TX_FLAGS 1
74 
75 #define BIOS_RX_RDY         0x01
76 #define BIOS_RX_CRC_ERROR   0x02
77 #define BIOS_RX_SIZE_ERROR  0x04
78 #define BIOS_TX_TO_SEND     0x01
79 #define BIOS_TX_WAIT_ON_ACK 0x02
80 #define BIOS_TX_NO_SEND     0x04
81 #define BIOS_TX_BUSY        0x08
82 
83 
84 #define BIOS_TX_TIMEOUT 50
85 
86 
87 struct _BiosRxRecord_
88 {
89     unsigned char  active;
90     unsigned char  last_cmd_typ;
91     unsigned char  last_msg_id;
92     unsigned short last_msg_call;
93     unsigned char  state[BIOS_RX_QUEUS];
94     unsigned char  *data[BIOS_RX_QUEUS];
95     unsigned short *datas[BIOS_RX_QUEUS];
96     unsigned short count[BIOS_RX_QUEUS];
97     unsigned short size[BIOS_RX_QUEUS];
98     unsigned short crc[2];
99 };
100 typedef struct _BiosRxRecord_ BiosRxRecord;
101 extern volatile BiosRxRecord bios_rx_record_;
102 
103 
104 struct _BiosTxRecord_
105 {
106     unsigned char  active;
107     unsigned char  cannel_to_send;
108     unsigned short send_counter[BIOS_TX_QUEUS];
109     unsigned short ack_timeout[BIOS_TX_QUEUS];
110     unsigned char  state[BIOS_TX_QUEUS];
111     unsigned short count[BIOS_TX_QUEUS];
112     unsigned short datas[BIOS_TX_QUEUS][BIOS_TX_SIZE/sizeof(unsigned short)];
113     unsigned char  *data[BIOS_TX_QUEUS];
114     unsigned short  *ext_data;
115     unsigned short ext_size;
116     unsigned short ext_counter;
117 };
118 typedef struct _BiosTxRecord_ BiosTxRecord;
119 extern volatile BiosTxRecord bios_tx_record_;
120 
121 struct _BiosGlobalTimer_
122 {
123     unsigned short count;
124     unsigned char state;
125 };
126 typedef struct _BiosGlobalTimer_ BiosGlobalTimer;
127 
128 #define BIOS_TIMER_BREAK 0x01
129 #define BIOS_TIMER_COUNT 2
130 #define BIOS_TIMER_RX 0
131 #define BIOS_TIMER_TX 1
132 
133 extern volatile BiosGlobalTimer bios_global_timer_[BIOS_TIMER_COUNT];
134 extern char bios_wb_control_;
135 extern const unsigned short core_version_;
136 extern __ro_placement volatile const unsigned short safe_core_version_;
137 extern unsigned long bios_device_flags_;
138 extern unsigned short bios_info_hw_0_;
139 extern unsigned short bios_info_hw_1_;
140 extern const unsigned short tool_id_;
141 #endif
142