Prusa MINI Firmware overview
filament_sensor.h
Go to the documentation of this file.
1 /*
2  * filament_sensor.h
3  *
4  * Created on: 2019-12-16
5  * Author: Radek Vana
6  */
7 
8 #ifndef _FILAMENT_SENSOR_H
9 #define _FILAMENT_SENSOR_H
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif //__cplusplus
14 
15 #pragma pack(push)
16 #pragma pack(1) //makes enum 1 BYTE
17 typedef enum {
18  FS_NOT_INICIALIZED, //enable enters this state too
23 } fsensor_t;
24 #pragma pack(pop)
25 
26 //thread safe functions
28 int fs_did_filament_runout(); //for arduino / marlin
29 
30 //switch behavior when M600 should be send
31 void fs_send_M600_on_edge(); //default behavior
33 void fs_send_M600_never();
34 
35 //thread safe functions, but cannot be called from interrupt
36 void fs_enable();
37 void fs_disable();
39 
40 //not thread safe functions
41 void fs_init_on_edge();
42 void fs_init_on_level();
43 void fs_init_never();
44 void fs_cycle(); //call it in thread, max call speed 1MHz
45 
46 #ifdef __cplusplus
47 }
48 #endif //__cplusplus
49 
50 #endif //_FILAMENT_SENSOR_H
M600_on_edge
Definition: filament_sensor.c:27
fs_enable
void fs_enable()
Definition: filament_sensor.c:90
fs_send_M600_on_edge
void fs_send_M600_on_edge()
Definition: filament_sensor.c:76
filament_sensor.h
task.h
fs_send_M600_on_edge
void fs_send_M600_on_edge()
Definition: filament_sensor.c:76
variant8_ui8
variant8_t variant8_ui8(uint8_t ui8)
Definition: variant8.c:18
marlin_client.h
status_t::meas_cycle
uint8_t meas_cycle
Definition: filament_sensor.c:35
EEVAR_FSENSOR_ENABLED
#define EEVAR_FSENSOR_ENABLED
Definition: eeprom.h:17
fs_init_never
void fs_init_never()
Definition: filament_sensor.c:132
send_M600_on_t
send_M600_on_t
Definition: filament_sensor.c:26
ExtUI::getProgress_percent
uint8_t getProgress_percent()
Definition: fake_uiapi.cpp:15
fs_get_state
fsensor_t fs_get_state()
Definition: filament_sensor.c:67
FS_DISABLED
Definition: filament_sensor.h:22
eeprom.h
fs_init_on_edge
void fs_init_on_edge()
Definition: filament_sensor.c:124
eeprom_get_var
variant8_t eeprom_get_var(uint8_t id)
Definition: eeprom.c:75
_variant8_t::ui8
uint8_t ui8
Definition: variant8.h:36
marlin_gcode_push_front
void marlin_gcode_push_front(const char *gcode)
Definition: marlin_client.c:222
state
static volatile fsensor_t state
Definition: filament_sensor.c:23
eeprom_set_var
void eeprom_set_var(uint8_t id, variant8_t var)
Definition: eeprom.c:88
fs_init_on_level
void fs_init_on_level()
Definition: filament_sensor.c:128
fs_send_M600_never
void fs_send_M600_never()
Definition: filament_sensor.c:84
FS_NOT_INICIALIZED
Definition: filament_sensor.h:18
_disable
static void _disable()
Definition: filament_sensor.c:59
GPIO_PULLUP
#define GPIO_PULLUP
Definition: stm32f4xx_hal_gpio.h:171
osDelay
osStatus osDelay(uint32_t millisec)
Wait for Timeout (Time Delay)
Definition: cmsis_os.c:365
gpio_get
static int gpio_get(uint8_t pin8)
Definition: gpio.h:94
MARLIN_VAR_WAITUSER
#define MARLIN_VAR_WAITUSER
Definition: marlin_vars.h:28
fs_init_on_edge
void fs_init_on_edge()
Definition: filament_sensor.c:124
FS_HAS_FILAMENT
Definition: filament_sensor.h:19
taskENTER_CRITICAL
#define taskENTER_CRITICAL()
Definition: task.h:217
_cycle1
static void _cycle1()
Definition: filament_sensor.c:177
GPIO_PULLDOWN
#define GPIO_PULLDOWN
Definition: stm32f4xx_hal_gpio.h:172
gpio_init
static void gpio_init(uint8_t pin8, uint32_t mode, uint32_t pull, uint32_t speed)
Definition: gpio.h:102
fs_did_filament_runout
int fs_did_filament_runout()
Definition: filament_sensor.c:72
fs_init_on_level
void fs_init_on_level()
Definition: filament_sensor.c:128
fs_send_M600_on_level
void fs_send_M600_on_level()
Definition: filament_sensor.c:80
ExtUI
Definition: fake_uiapi.cpp:9
ExtUI::isMoving
bool isMoving()
Definition: fake_uiapi.cpp:11
MARLIN_VAR_WAITHEAT
#define MARLIN_VAR_WAITHEAT
Definition: marlin_vars.h:27
_injectM600
static void _injectM600()
Definition: filament_sensor.c:139
FS_NO_FILAMENT
Definition: filament_sensor.h:20
fs_get_state
fsensor_t fs_get_state()
Definition: filament_sensor.c:67
GPIO_SPEED_FREQ_VERY_HIGH
#define GPIO_SPEED_FREQ_VERY_HIGH
Definition: stm32f4xx_hal_gpio.h:161
gpio.h
marlin_update_vars
marlin_vars_t * marlin_update_vars(uint64_t msk)
Definition: marlin_client.c:368
_marlin_vars_t::wait_user
uint8_t wait_user
Definition: marlin_vars.h:92
FreeRTOS.h
PIN_FSENSOR
#define PIN_FSENSOR
Definition: hwio_pindef.h:44
uint8_t
const uint8_t[]
Definition: 404_html.c:3
MARLIN_VAR_MSK
#define MARLIN_VAR_MSK(v_id)
Definition: marlin_vars.h:35
_set_state
static void _set_state(fsensor_t st)
Definition: filament_sensor.c:44
ui
MarlinUI ui
status_t::M600_sent
uint8_t M600_sent
Definition: filament_sensor.c:33
fs_send_M600_on_level
void fs_send_M600_on_level()
Definition: filament_sensor.c:80
M600_never
Definition: filament_sensor.c:29
status_t::send_M600_on
uint8_t send_M600_on
Definition: filament_sensor.c:34
MARLIN_VAR_SD_PRINT
#define MARLIN_VAR_SD_PRINT
Definition: marlin_vars.h:29
M600_on_level
Definition: filament_sensor.c:28
stm32f4xx_hal.h
This file contains all the functions prototypes for the HAL module driver.
fs_cycle
void fs_cycle()
Definition: filament_sensor.c:185
status
static status_t status
Definition: filament_sensor.c:37
fs_send_M600_never
void fs_send_M600_never()
Definition: filament_sensor.c:84
FS_NOT_CONNECTED
Definition: filament_sensor.h:21
_marlin_vars_t
Definition: marlin_vars.h:77
fs_wait_inicialized
fsensor_t fs_wait_inicialized()
Definition: filament_sensor.c:104
last_state
static volatile fsensor_t last_state
Definition: filament_sensor.c:24
_cycle0
static void _cycle0()
Definition: filament_sensor.c:147
fsensor_t
fsensor_t
Definition: filament_sensor.h:17
hwio_pindef.h
taskEXIT_CRITICAL
#define taskEXIT_CRITICAL()
Definition: task.h:232
GPIO_MODE_INPUT
#define GPIO_MODE_INPUT
Definition: stm32f4xx_hal_gpio.h:135
fs_disable
void fs_disable()
Definition: filament_sensor.c:97
fs_enable
void fs_enable()
Definition: filament_sensor.c:90
fs_cycle
void fs_cycle()
Definition: filament_sensor.c:185
fs_init_never
void fs_init_never()
Definition: filament_sensor.c:132
_init
static void _init()
Definition: filament_sensor.c:115
fs_did_filament_runout
int fs_did_filament_runout()
Definition: filament_sensor.c:72
fs_disable
void fs_disable()
Definition: filament_sensor.c:97
_marlin_vars_t::sd_printing
uint8_t sd_printing
Definition: marlin_vars.h:93
cmsis_os.h
Header of cmsis_os.c A new set of APIs are added in addition to existing ones, these APIs are specifi...
fs_wait_inicialized
fsensor_t fs_wait_inicialized()
Definition: filament_sensor.c:104
status_t
Definition: filament_sensor.c:32
Planner::has_blocks_queued
static FORCE_INLINE bool has_blocks_queued()
Definition: planner.h:762
planner
Planner planner
Definition: planner.cpp:111
_enable
static void _enable()
Definition: filament_sensor.c:52