]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blob - source/mout.c
Added commands for read values from DIN and MOUT ports
[pes-rpp/rpp-test-sw.git] / source / mout.c
1 /*
2  * mout.c
3  *
4  *  Created on: 29.8.2012
5  *      Author: michal
6  */
7
8 #include "mout.h"
9
10 gioPORT_t * moutPorts[12] = {   MOUT_PORT_HET, MOUT_PORT_HET, MOUT_PORT_GIO,
11                                                         MOUT_PORT_GIO, MOUT_PORT_GIO, MOUT_PORT_GIO,
12                                                         MOUT_PORT_SPI, MOUT_PORT_SPI, MOUT_PORT_GIO,
13                                                         MOUT_PORT_GIO, MOUT_PORT_GIO, MOUT_PORT_GIO
14                                                   };
15 uint8_t moutBits[12] ={ MOUT1_IN_BIT, MOUT2_IN_BIT, MOUT3_IN_BIT,
16                                                 MOUT4_IN_BIT, MOUT5_IN_BIT, MOUT6_IN_BIT,
17                                                 MOUT1_EN_BIT, MOUT2_EN_BIT, MOUT3_EN_BIT,
18                                                 MOUT4_EN_BIT, MOUT5_EN_BIT, MOUT6_EN_BIT
19                                         };
20
21 /** @fn void moutSetPort(uint32_t value)
22 *   @brief Set value to ports connected to MOUT
23 *   @param[in] value to write to port
24 *                       - bit 0 - MOUT1_IN - defined as output port HETPORT1
25 *                       - bit 1 - MOUT2_IN - defined as output port HETPORT1
26 *                       - bit 2 - MOUT3_IN - defined as output port GIOB
27 *                       - bit 3 - MOUT4_IN - defined as output port GIOB
28 *                       - bit 4 - MOUT5_IN - defined as output port GIOB
29 *                       - bit 5 - MOUT6_IN - defined as output port GIOB
30 *                       - bit 6 - MOUT1_EN - defined as input port SPIPORT
31 *                       - bit 7 - MOUT2_EN - defined as input port SPIPORT
32 *                       - bit 8 - MOUT3_EN - defined as input port GIOB
33 *                       - bit 9 - MOUT4_EN - defined as input port GIOB
34 *                       - bit 10 - MOUT5_EN - defined as input port GIOB
35 *                       - bit 11 - MOUT6_EN - defined as input port GIOB
36 *   Set value to whole MOUT port. Setting values to bits connected with ports defined as output makes no effect.
37 */
38 void moutSetPort(uint32_t value) {
39         uint8_t i;
40         for (i = 0; i < 12; i++) {
41                 gioSetBit(moutPorts[i], moutBits[i], value&(1<<i));
42         }
43 }
44
45 /** @fn void moutGetPort()
46 *   @brief Get value from ports connected to MOUT
47 *                       - bit 0 - MOUT1_IN - defined as output port HETPORT1
48 *                       - bit 1 - MOUT2_IN - defined as output port HETPORT1
49 *                       - bit 2 - MOUT3_IN - defined as output port GIOB
50 *                       - bit 3 - MOUT4_IN - defined as output port GIOB
51 *                       - bit 4 - MOUT5_IN - defined as output port GIOB
52 *                       - bit 5 - MOUT6_IN - defined as output port GIOB
53 *                       - bit 6 - MOUT1_EN - defined as input port SPIPORT
54 *                       - bit 7 - MOUT2_EN - defined as input port SPIPORT
55 *                       - bit 8 - MOUT3_EN - defined as input port GIOB
56 *                       - bit 9 - MOUT4_EN - defined as input port GIOB
57 *                       - bit 10 - MOUT5_EN - defined as input port GIOB
58 *                       - bit 11 - MOUT6_EN - defined as input port GIOB
59 *   Get value from whole MOUT port. Getting values from ports defined as output returns values last asserted by Controller itself.
60 */
61 uint32_t moutGetPort() {
62         uint8_t i;
63         uint32_t value = 0;
64         for (i = 0; i < 12; i++) {
65                 value |= (gioGetBit(moutPorts[i], moutBits[i])<<i);
66         }
67         return value;
68 }