CuVoodoo STM32F1 firmware template
Data Structures | Macros | Functions | Variables
main.c File Reference

CuVoodoo clapperboard firmware (for STM32F103Cx micro-controller) More...

Go to the source code of this file.

Data Structures

struct  number_t
 number to be display and changed using the buttons More...
 

Macros

#define WATCHDOG_PERIOD   10000
 watchdog period in ms
 
#define POWER_SWITCH_PORT   B
 port to switch power of all devices (including this micro-controller)
 
#define POWER_SWITCH_PIN   8
 pin to switch power of all devices (including this micro-controller)
 
#define POWER_BUTTON_PORT   B
 port to detect power switching activity by shaking (to keep alive)
 
#define POWER_BUTTON_PIN   1
 pin to detect power switching activity by shaking (to keep alive)
 
#define SQUARE_WAVE_PORT   B
 port connected to RTC DS1307 square wave output
 
#define SQUARE_WAVE_PIN   0
 pin connected to RTC DS1307 square wave output
 
#define STANDBY_TIMEOUT   30
 number of seconds after last shake before going down
 
#define FRAME_TIMER   2
 timer to count frame time
 
#define FRAME_RATE   25
 frame rate in frames per second
 
#define BUZZER_TIMER   1
 timer to generate scene and take count
 
#define BUZZER_1_PORT   A
 use timer channel 1 (and it's negative) to driver buzzer
 
#define BUZZER_1_PIN   7
 use timer channel 1 (and it's negative) to driver buzzer
 
#define BUZZER_2_PORT   A
 use timer channel 1 (and it's negative) to driver buzzer
 
#define BUZZER_2_PIN   8
 use timer channel 1 (and it's negative) to driver buzzer
 
#define MUX_EN_PORT   B
 port to enable multiplexer
 
#define MUX_EN_PIN   9
 pin to enable multiplexer
 
#define MUX_S0_PORT   B
 port to select multiplexer output
 
#define MUX_S0_PIN   3
 pin to select multiplexer output
 
#define MUX_S1_PORT   B
 port to select multiplexer output
 
#define MUX_S1_PIN   4
 pin to select multiplexer output
 
#define MUX_S2_PORT   B
 port to select multiplexer output
 
#define MUX_S2_PIN   5
 pin to select multiplexer output
 
#define BUTTON_SECONDS_UP   9
 which of the 16 buttons is to increment the seconds
 
#define BUTTON_SECONDS_DOWN   13
 which of the 16 buttons is to decrement the seconds
 
#define BUTTONS_DRIVE_PORT   A
 port used to drive the buttons rows
 
#define BUTTONS_DRIVE_PIN0   0
 pin used to drive buttons row 0
 
#define BUTTONS_DRIVE_PIN1   1
 pin used to drive buttons row 1
 
#define BUTTONS_DRIVE_PIN2   2
 pin used to drive buttons row 2
 
#define BUTTONS_DRIVE_PIN3   3
 pin used to drive buttons row 3
 
#define BUTTONS_READ_PORT   A
 port used to read the buttons columns
 
#define BUTTONS_READ_PIN0   4
 pin used to read buttons column 0
 
#define BUTTONS_READ_PIN1   5
 pin used to read buttons column 1
 
#define BUTTONS_READ_PIN2   6
 pin used to read buttons column 2
 
#define BUTTONS_READ_PIN3   15
 pin used to read buttons column 3
 
#define CLAP_BUTTON_PORT   B
 port for button to detect clap action
 
#define CLAP_BUTTON_PIN   14
 port for button to detect clap action
 
#define MORSE_DOT   1
 Morse code variables, to buzz/beep scene and take. More...
 

Functions

size_t putc (char c)
 print a single character on user output More...
 
static void process_command (char *str)
 process user command More...
 
static void mux_select (uint8_t output)
 select clock output for TM1637 display using the analog multiplexer More...
 
static void encode_morse (void)
 encode scene and take into Morse code (in morse variable)
 
void main (void)
 program entry point this is the firmware function started by the micro-controller
 
void EXTI_ISR() SQUARE_WAVE_PIN (void)
 RTC square wave input ISR to synchronize to seconds and count them.
 
void TIM_ISR() FRAME_TIMER (void)
 frame timer ISR
 
void EXTI_ISR() POWER_BUTTON_PIN (void)
 power switch/keep alive activity
 
void EXTI_ISR() CLAP_BUTTON_PIN (void)
 clap
 

Variables

volatile bool rtc_tick_flag = false
 flag set when RTC ticked
 
volatile bool frame_flag = false
 flag set when a frame has passed
 
volatile bool keep_alive_flag = false
 flag to restart shutdown counter on power switch activity
 
volatile bool clap_flag = false
 flag set on clap
 
volatile uint8_t rtc_seconds = 0
 number of seconds passed, incremented by the square wave
 
volatile uint16_t standby_timer = 0
 number of seconds since last power-up activity (using shake sensor)
 
volatile uint8_t frame_count = 0
 number of frames passed
 
struct number_t numbers []
 episode, scene, take, video 1, audio 1, video 2, audio 2 number (in this order) More...
 
uint8_t morse [2 *4 *5 *2] = {0}
 to encode 2 4-digit numbers (scene and take) into Morse code (5 sign+space)
 
uint8_t morse_i = 0
 index in Morse array
 
int16_t morse_delay = -1
 number of frames before beeping (-1=no need to beep yet, -2=beeping completed)
 
static char command [32] = {0}
 user input command
 
uint8_t command_i = 0
 user input command index
 

Detailed Description

CuVoodoo clapperboard firmware (for STM32F103Cx micro-controller)

Author
King Kévin kingk.nosp@m.evin.nosp@m.@cuvo.nosp@m.odoo.nosp@m..info
Date
2016-2017

Definition in file main.c.

Macro Definition Documentation

◆ MORSE_DOT

#define MORSE_DOT   1

Morse code variables, to buzz/beep scene and take.

unit Morse code duration in frames

Definition at line 126 of file main.c.

Function Documentation

◆ mux_select()

static void mux_select ( uint8_t  output)
static

select clock output for TM1637 display using the analog multiplexer

Parameters
[in]outputclock output channel

Definition at line 243 of file main.c.

◆ process_command()

static void process_command ( char *  str)
static

process user command

Parameters
[in]struser command string (\0 ended)

Definition at line 165 of file main.c.

◆ putc()

size_t putc ( char  c)

print a single character on user output

Warning
this must be implemented by the user (using the desired output interface)
Parameters
[in]ccharacter to be printed
Returns
number of characters printed

Definition at line 136 of file main.c.

Variable Documentation

◆ numbers

struct number_t numbers[]
Initial value:
= {
{0, 0, 4, 4},
{0, 8, 12, 5},
{0, 1, 5, 6},
{0, 2, 6, 3},
{0, 10, 14, 2},
{0, 3, 7, 1},
{0, 11, 15, 0},
}

episode, scene, take, video 1, audio 1, video 2, audio 2 number (in this order)

Definition at line 98 of file main.c.