|
spinnaker_tools (BMP) latest
SpiNNaker BMP firmware
|
Low-level hardware interface code for BMP LPC1768. More...
#include <string.h>#include "lpc17xx.h"#include "lpc17xx_pinsel.h"#include "lpc17xx_clkpwr.h"#include "bmp.h"Macros | |
| #define | ADC_PCLK 25000000 |
| 25 MHz | |
| #define | ADC_CLK 13000000 |
| 13 MHz | |
| #define | ADC_PDN (1 << 21) |
| #define | ADC_VALID 0xde |
| Channels 0, 5 not used on Spin5. | |
| #define | SYSRAM_IP_DATA 0xf5007fe0 |
| System RAM IP address data. | |
Port 3 | |
| #define | P3_EN (XFSEL_0 + XFSEL_1) |
| #define | P3_INIT (XFSEL_0 + XFSEL_1) |
Port 4 | |
| #define | P4_EN (XFSEL_2) |
| #define | P4_INIT (XFSEL_2) |
Functions | |
| uint32_t | cpu_int_off (void) |
| Disable interrupts. | |
| void | cpu_int_restore (uint32_t cpsr) |
| Restore interrupts. | |
| void | clock_div (uint32_t bit_pos, uint32_t value) |
| Configure clock division. | |
| void | set_power (uint32_t state) |
| Turn board off or on. | |
| void | led_set (uint32_t leds) |
| Control the LEDs. | |
| void | fpga_reset (uint32_t code) |
| Reset the FPGAs. | |
| uint32_t | fpga_init (uint32_t mask) |
| Initialise FPGAs. | |
| static void | configure_adc (void) |
| Configure analog-to-digital converters for voltage monitoring. | |
| void | read_adc (void) |
| Read voltage from an ADC (directly into board_stat_t::adc) and start the read of the next ADC. | |
| static void | configure_wdt (uint32_t period) |
| Configure the watchdog timer. | |
| void | refresh_wdt (void) |
| Refresh the watchdog timer so that the watchdog doesn't bark. | |
| static void | process_reset (void) |
| Reset critical vectors and timers. | |
| void | configure_pwm (uint32_t period, uint32_t width) |
| Configure pulse-width modulation hardware. | |
| static void | timer_init (LPC_TIM_TypeDef *timer, uint32_t channel, uint32_t value) |
| Configure a timer. | |
| static void | configure_timers (void) |
| Configure periodic timers. | |
| static void | set_pin_mf (uint32_t port, uint32_t pin, uint32_t mode, uint32_t function) |
| Set pin mode and function. | |
| static void | set_pin_od (uint32_t port, uint32_t pin, uint32_t mode) |
| Set pin operation: open-drain or normal. | |
| static void | config_pin (uint32_t port, uint32_t pin, uint32_t func) |
| Set pin function. | |
| void | ssp0_pins (uint32_t on) |
| Set up GPIO pins that talk to Flash. | |
| static uint32_t | configure_pins (void) |
| Configure pins for talking to external peripherals. | |
| void | reset_spin (uint32_t code) |
| Resets SpiNNaker by raising/lowering POR and switching the Serial Flash multiplexer as needed when POR falls. | |
| static void | configure_mcpwm (void) |
| Set up a 300kHz 120 degree duty-cycle waveform on three outputs MC0B0, MC0B1, MC0B2 (NB outputs not enabled on Spin4) | |
| void | read_fans (void) |
| Count transitions on the fan sensor inputs. | |
| void | read_temp (void) |
| Read I2C temperature sensors and also compute the fan speed. | |
| void | die (uint32_t code) |
| Curl up and die (probably because of hardware failure or misconfiguration. | |
| void | delay_us (uint32_t n) |
| Delay using a busy loop. | |
| void | delay_ms (uint32_t n) |
| Delay using a busy loop. | |
| static void | configure_spin (void) |
| void | proc_setup (uint32_t d1, uint32_t d2) |
| Set up networking. Handles remote request across CAN from BMP master. | |
| void | configure_hw (void) |
| Configure the BMP hardware. | |
Variables | |
| board_stat_t | board_stat [CAN_SIZE] |
| Board status. | |
| static uint32_t | adc_chan |
| Current ADC channel (see read_adc()) | |
| uint8_t | can_ID |
| CAN ID (from backplane) | |
| uint8_t | board_ID |
| Board ID (devived from can_ID) | |
| bool | bp_ctrl |
| Backplane controller. | |
| bool | fan_sense |
| Compute fan speed. | |
| uint8_t | power_state |
| Power supply state. | |
| ee_data_t | ee_data |
| Copy of EEPROM data. | |
| uint32_t | config1 |
Argument d1 to pass to proc_setup() | |
| uint32_t | config2 |
Argument d2 to pass to proc_setup() | |
| const uint8_t * | can2board |
| Mapping from CAN ID to board number. | |
| const uint8_t * | board2can |
| Mapping from board number to CAN ID. | |
| const uint32_t | hw_ver = 5 |
| Hardware version. | |
| static const uint32_t | led_bit [] |
| Mapping from LED index to GPIO pin flags. | |
| static uint32_t | fan_last [4] |
| Last fan state. | |
| static uint16_t | fan_count [4] |
| Fan rotation counter. | |
| static const uint8_t | can2board_0 [] |
| Default mapping from CAN ID to board number, for can2board. | |
| static const uint8_t | board2can_0 [] |
| Default mapping from board number to CAN ID, for board2can. | |
| static const uint8_t | null_map [] |
| Null mapping, used when not in a frame. One-to-one. | |
| static const ee_data_t | ee_default |
| Default "EEPROM" data, when EEPROM fails. | |
Port 0 | |
| #define | P0_EN (SF_NCS + IO_EN1 + LED_MASK) |
| #define | P0_INIT (SF_NCS + IO_EN1 + LED_0) |
| enum | gpio_bits_port_0 { FAN_ED2 = (1 << 6) , IO_EN1 = (1 << 23) , I2C_SDA = (1 << 27) , I2C_SCL = (1 << 28) } |
Port 1 | |
| #define | P1_EN (EN_V12 + EN_V18 + EN_VFPGA + XPROGB_0 + XPROGB_1 + XPROGB_2 + XIL_RST) |
| #define | P1_INIT (EN_V12 + EN_V18 + XPROGB_0 + XPROGB_1 + XPROGB_2) |
| enum | gpio_bits_port_1 { XIL_RST = (1 << 14) , EN_V12 = (1 << 18) , EN_V18 = (1 << 19) , EN_VFPGA = (1 << 20) , XPROGB_0 = (1 << 21) , XPROGB_1 = (1 << 23) , XPROGB_2 = (1 << 24) , XDONE = (1 << 31) } |
Port 2 | |
| #define | XINIT_B (XINITB_0 + XINITB_1 + XINITB_2) |
| #define | P2_EN (BOOT_1 + POR + RST + IO_EN2 + IO_6 + IO_7 + IO_8 + IO_9) |
| #define | P2_INIT (IO_6 + IO_EN2) |
| BootROM + serial + POST. | |
| enum | gpio_bits_port_2 { BOOT_1 = (1 << 0) , IO_6 = (1 << 1) , IO_7 = (1 << 2) , IO_8 = (1 << 3) , IO_9 = (1 << 4) , FAN_PWM = (1 << 5) , POR = (1 << 6) , RST = (1 << 7) , FAN_ED0 = (1 << 8) , FAN_ED1 = (1 << 9) , IO_EN2 = (1 << 10) , XINITB_0 = (1 << 11) , XINITB_1 = (1 << 12) , XINITB_2 = (1 << 13) } |
Low-level hardware interface code for BMP LPC1768.
| enum gpio_bits_port_0 |
| enum gpio_bits_port_1 |
| enum gpio_bits_port_2 |
| uint32_t cpu_int_off | ( | void | ) |
Disable interrupts.
| void cpu_int_restore | ( | uint32_t | cpsr | ) |
Restore interrupts.
| [in] | cpsr | old CPSR state to restore |
| void clock_div | ( | uint32_t | bit_pos, |
| uint32_t | value | ||
| ) |
Configure clock division.
| bit_pos | the bit position to configure |
| value | the value of that bit |
| void set_power | ( | uint32_t | state | ) |
Turn board off or on.
| [in] | state | State to go into. |
| void led_set | ( | uint32_t | leds | ) |
Control the LEDs.
| [in] | leds | Encoded packed LED control word. Two bits per LED: 0 = ignore, 1 = toggle, 2 = turn off, 3 = turn on. |
| void fpga_reset | ( | uint32_t | code | ) |
Reset the FPGAs.
| [in] | code | How to do the reset. 0 = clear reset line, 1 = set reset line, 2 = cycle reset line |
| uint32_t fpga_init | ( | uint32_t | mask | ) |
Initialise FPGAs.
| [in] | mask | Which FPGAs to initialise |
| void read_adc | ( | void | ) |
Read voltage from an ADC (directly into board_stat_t::adc) and start the read of the next ADC.
This is called approx every 80ms from proc_100hz().
|
static |
Configure the watchdog timer.
| [in] | period | Timer period |
| void configure_pwm | ( | uint32_t | period, |
| uint32_t | width | ||
| ) |
Configure pulse-width modulation hardware.
| [in] | period | Overall period |
| [in] | width | Pulse width. No longer than than period. |
|
static |
Configure a timer.
| [in] | timer | The timer to configure |
| [in] | channel | The channel to put a timer on |
| [in] | value | Timer match value |
|
static |
Set pin mode and function.
| [in] | port | Port index |
| [in] | pin | Pin number |
| [in] | mode | Mode |
| [in] | function | Function |
|
static |
Set pin operation: open-drain or normal.
| [in] | port | Port index |
| [in] | pin | Pin number |
| [in] | mode | Mode |
|
static |
Set pin function.
| [in] | port | Port index |
| [in] | pin | Pin number |
| [in] | func | Function |
| void ssp0_pins | ( | uint32_t | on | ) |
Set up GPIO pins that talk to Flash.
| [in] | on | True to enable |
|
static |
Configure pins for talking to external peripherals.
GPIO, CAN, Serial Flash, LED, I2C, Ethernet, FPGA
| void reset_spin | ( | uint32_t | code | ) |
Resets SpiNNaker by raising/lowering POR and switching the Serial Flash multiplexer as needed when POR falls.
| [in] | code | How to do the reset |
code = 0 - lower POR (reset off) code = 1 - raise POR (reset on) code = 2 - pulse POR
If Bit 2 of code is set then the FPGAs are also reset
The Serial Flash is dual ported on Spin5 and the SpiNNaker root chip reads its IP address from it just after it is reset. The read takes about 12ms for the 'standard' IP address block of 32 bytes. If the Serial Flash is set up to contain more code, the delay of 20ms will need to be increased.
| void read_fans | ( | void | ) |
Count transitions on the fan sensor inputs.
This routine is called once per millisec and it's assumed that the fan speed is low enough for there to be no more than one transition per ms.
| void read_temp | ( | void | ) |
Read I2C temperature sensors and also compute the fan speed.
This routine is called once per second.
| void die | ( | uint32_t | code | ) |
Curl up and die (probably because of hardware failure or misconfiguration.
The top LED is turned on (Red on Spin5) and the code is put on the next 4 LEDs (Green on Spin5). The bottom 3 LEDs are turned off.
| [in] | code | Failure code to indicate in LEDs |
| void delay_us | ( | uint32_t | n | ) |
Delay using a busy loop.
| [in] | n | How many μs to delay for |
| void delay_ms | ( | uint32_t | n | ) |
Delay using a busy loop.
| [in] | n | How many milliseconds to delay for |
|
static |
Copy the SpiNNaker IP address from buffer in memory (spin_ip) to the bottom of the serial Flash. The 32 bytes of data is padded with the necessary control codes to allow SpiNNaker to load the address block. The first 44 bytes of the serial Flash are used for this. The data is only updated if it is different from the buffer.
Word 12 is used to hold a count of the number of times the update has occurred. If more load blocks are needed this word can form the single entry in a dummy load block.
| void proc_setup | ( | uint32_t | d1, |
| uint32_t | d2 | ||
| ) |
Set up networking. Handles remote request across CAN from BMP master.
| [in] | d1 | Combined hardware version, count of zero IP netmask bits, and frame ID |
| [in] | d2 | IP gateway address. (Local addresses derive from this, frame ID and board ID.) |
|
static |
Mapping from LED index to GPIO pin flags.
|
static |
Default mapping from CAN ID to board number, for can2board.
|
static |
Default mapping from board number to CAN ID, for board2can.
|
static |
Null mapping, used when not in a frame. One-to-one.
|
static |
Default "EEPROM" data, when EEPROM fails.