openMMC
Open Source Modular MMC for AMCs
Loading...
Searching...
No Matches
fpga_spi.h
Go to the documentation of this file.
1/*
2 * openMMC -- Open Source modular IPM Controller firmware
3 *
4 * Copyright (C) 2015-2016 Henrique Silva <henrique.silva@lnls.br>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+>
20 */
21
22#ifndef FPGA_SPI_H_
23#define FPGA_SPI_H_
24
25#include <assert.h>
26
27#include "sdr.h"
28#include "utils.h"
29
30#define FPGA_UPDATE_RATE 5000 // in ms
31#define FPGA_MEM_ADDR_MAX 0xFF
32
33#define WR_COMMAND 0x80
34#define RD_COMMAND 0x00
35
36#define NO_DIAG 0x00
37#define FPGA_TEMP_DEVID 0x01
38#define FMC1_TEMP_DEVID 0x02
39#define FMC2_TEMP_DEVID 0x03
40#define DCDC_TEMP_DEVID 0x04
41#define RAM_TEMP_DEVID 0x05
42#define FMC1_12V_CURR_DEVID 0x06
43#define FMC1_P3V3_CURR_DEVID 0x07
44#define FMC1_VADJ_CURR_DEVID 0x08
45#define FMC2_12V_CURR_DEVID 0x09
46#define FMC2_P3V3_CURR_DEVID 0x0A
47#define FMC2_VADJ_CURR_DEVID 0x0B
48#define FMC1_12V_DEVID 0x0C
49#define FMC1_P3V3_DEVID 0x0D
50#define FMC1_VADJ_DEVID 0x0E
51#define FMC2_12V_DEVID 0x0F
52#define FMC2_P3V3_DEVID 0x10
53#define FMC2_VADJ_DEVID 0x11
54
55
56typedef struct __attribute__ ((__packed__)) {
57#ifdef BF_MS_FIRST
58 uint8_t dev_id;
59 uint32_t measure:24;
60#else
61 uint32_t measure:24;
62 uint8_t dev_id;
63#endif
65
66typedef struct __attribute__ ((__packed__)) {
67#ifdef BF_MS_FIRST
68 uint32_t reserved:26,
69 fmc2_pg_c2m:1,
70 fmc1_pg_c2m:1,
71 fmc2_pg_m2c:1,
72 fmc1_pg_m2c:1,
73 fmc2_prsnt_m2c_n:1,
74 fmc1_prsnt_m2c_n:1;
75#else
76 uint32_t fmc1_prsnt_m2c_n:1,
77 fmc2_prsnt_m2c_n:1,
78 fmc1_pg_m2c:1,
79 fmc2_pg_m2c:1,
80 fmc1_pg_c2m:1,
81 fmc2_pg_c2m:1,
82 reserved:26;
83#endif
85
89typedef struct __attribute__ ((__packed__,aligned(4))) {
90 uint32_t cardID[4];
91 uint32_t slot_id:16,
92 ipmi_addr:16;
93 uint32_t data_valid;
95 fmc_diag_t fmc_slot;
97
98/* Guarantee buffer can be read as an uint32_t array
99 * FIXME: use static_assert when moving build to C11 */
100_Static_assert(sizeof(board_diagnostic_t) % sizeof(uint32_t) == 0);
101
110void vTaskFPGA_COMM( void * Parameters );
111
116void fpga_spi_init( void );
117
118#endif
sensor_diag_t
Definition fpga_spi.h:64
fmc_diag_t
Definition fpga_spi.h:84
void vTaskFPGA_COMM(void *Parameters)
FPGA Diagnostics Task.
Definition fpga_spi.c:64
void fpga_spi_init(void)
Initializes the FPGA Diagnostics Task.
Definition fpga_spi.c:126
struct __attribute__((__packed__))
Definition fpga_spi.h:56
board_diagnostic_t
Definition fpga_spi.h:96
#define NUM_SENSOR
Definition sdr.h:28
General utilities functions.