Prusa MINI Firmware overview
diag.c File Reference
#include "diag.h"
#include "otp.h"
#include "gpio.h"
#include "stm32f4xx_hal.h"
#include "w25x.h"
#include "st25dv64k.h"
#include "usb_host.h"

Functions

void diag_delay (int delay)
 
void diag_check_fastboot (void)
 
int diag_eeprom ()
 
void diag_test (void)
 

Variables

int diag_fastboot = 0
 
int diag_error = 0
 
ApplicationTypeDef Appli_state
 

Function Documentation

◆ diag_delay()

void diag_delay ( int  delay)
17  {
18  volatile int i;
19  for (i = 0; i < delay; i++) {
20  }
21 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ diag_check_fastboot()

void diag_check_fastboot ( void  )
23  {
24  if (otp_lock_sector0) //not locked
25  {
28  diag_delay(100000);
29  int i;
30  for (i = 0; i < 10; i++) {
31  if (gpio_get(PC7))
32  break;
33  diag_delay(10000);
34  }
35  diag_fastboot = ((i == 10) && !gpio_get(PC7)) ? 1 : 0;
36  }
37 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ diag_eeprom()

int diag_eeprom ( )
39  {
40  int ee_adress = 0x00;
41  int ee_data = 0x56;
42  int diag_eeprom;
44  st25dv64k_user_write(ee_adress, ee_data);
45  diag_eeprom = (st25dv64k_user_read(ee_adress) == ee_data) ? 1 : 0;
46  return diag_eeprom;
47 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ diag_test()

void diag_test ( void  )
49  {
50  diag_error = 0;
51  //SPI DIAG
52  if (diag_error == 0)
53  if (!w25x_init())
55 
56  //I2C EEPROM
57  if (diag_error == 0)
58  if (!diag_eeprom())
60 
61  //USBA
62  if (diag_error == 0)
65 }
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ diag_fastboot

int diag_fastboot = 0

◆ diag_error

int diag_error = 0

◆ Appli_state

ApplicationTypeDef Appli_state
st25dv64k_init
void st25dv64k_init(void)
Definition: st25dv64k.c:73
i
uint8_t i
Definition: screen_test_graph.c:72
DIAG_ERR_SPIFLASH
#define DIAG_ERR_SPIFLASH
Definition: diag.h:9
diag_fastboot
int diag_fastboot
Definition: diag.c:11
diag_delay
void diag_delay(int delay)
Definition: diag.c:17
st25dv64k_user_write
void st25dv64k_user_write(uint16_t address, uint8_t data)
Definition: st25dv64k.c:103
PC7
#define PC7
Definition: variant.h:73
GPIO_PULLUP
#define GPIO_PULLUP
Definition: stm32f4xx_hal_gpio.h:171
gpio_get
static int gpio_get(uint8_t pin8)
Definition: gpio.h:94
APPLICATION_READY
Definition: usb_host.h:88
gpio_init
static void gpio_init(uint8_t pin8, uint32_t mode, uint32_t pull, uint32_t speed)
Definition: gpio.h:102
otp_lock_sector0
#define otp_lock_sector0
Definition: otp.h:29
GPIO_SPEED_FREQ_VERY_HIGH
#define GPIO_SPEED_FREQ_VERY_HIGH
Definition: stm32f4xx_hal_gpio.h:161
delay
void delay(uint32_t ms)
Definition: wiring_time.c:42
__HAL_RCC_GPIOC_CLK_ENABLE
#define __HAL_RCC_GPIOC_CLK_ENABLE()
Definition: stm32f4xx_hal_rcc.h:416
Appli_state
ApplicationTypeDef Appli_state
Definition: usb_host.c:75
DIAG_ERR_USBA
#define DIAG_ERR_USBA
Definition: diag.h:10
DIAG_ERR_I2CEEPROM
#define DIAG_ERR_I2CEEPROM
Definition: diag.h:8
diag_eeprom
int diag_eeprom()
Definition: diag.c:39
diag_error
int diag_error
Definition: diag.c:13
GPIO_MODE_INPUT
#define GPIO_MODE_INPUT
Definition: stm32f4xx_hal_gpio.h:135
st25dv64k_user_read
uint8_t st25dv64k_user_read(uint16_t address)
Definition: st25dv64k.c:93
w25x_init
int8_t w25x_init(void)
Definition: w25x.c:57