ASCII Serial Com
Serial communication library between computers, microcontrollers, FPGAs, etc. Uses only ASCII. Not the most efficient protocol, but meant to be easy to read
Loading...
Searching...
No Matches
Macros | Functions | Variables
stm32f091nucleo64_pulser.c File Reference

Outputs a pulser and (one day will) measures pulses. More...

#include <libopencm3/cm3/cortex.h>
#include <libopencm3/cm3/nvic.h>
#include <libopencm3/stm32/adc.h>
#include <libopencm3/stm32/dac.h>
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/timer.h>
#include <libopencm3/stm32/usart.h>
#include "arm/stm_timers.h"
#include "arm/stm_usart.h"
#include "asc_exception.h"
#include "asc_helpers.h"
#include "ascii_serial_com.h"
#include "ascii_serial_com_device.h"
#include "ascii_serial_com_register_pointers.h"
#include "circular_buffer.h"
#include "millisec_timer.h"
Include dependency graph for stm32f091nucleo64_pulser.c:

Go to the source code of this file.

Macros

#define ASC_USART_NO   2
 
#define ASC_USART   USART2
 
#define PORT_LED   GPIOA
 
#define PIN_LED   GPIO5
 
#define RCC_GPIO_LED   RCC_GPIOA
 
#define TIM_LED   TIM2
 
#define TIM_OC_LED   TIM_OC1
 
#define RCC_TIM_LED   RCC_TIM2
 
#define AF_TIM_LED   GPIO_AF2
 
#define pulser_tick_freq   1000
 
#define pulser_period   1000
 
#define pulser_width   500
 
#define IC_PORT   GPIOA
 
#define IC_PIN   GPIO8
 
#define IC_RCC_GPIO   RCC_GPIOA
 
#define IC_TIM   TIM1
 
#define IC_RCC_TIM   RCC_TIM1
 
#define IC_TI   TIM_IC_IN_TI1
 
#define IC_AF   GPIO_AF2
 
#define nRegs   10
 

Functions

 DECLARE_ASC_DEVICE_W_REGISTER_POINTERS () uint8_t tmp_byte=0
 
int main (void)
 

Variables

uint32_t ic_pulse_length
 
uint32_t ic_period
 
uint32_t ic_overrun
 
CEXCEPTION_T e
 
uint16_t nExceptions
 
 MILLISEC_TIMER_SYSTICK_IT
 
uint32_t optionFlags = 0
 
volatile REGTYPE * register_map [nRegs]
 Register Map.
 
REGTYPE register_write_masks [nRegs]
 Write masks for register_map.
 

Detailed Description

Outputs a pulser and (one day will) measures pulses.

Outputs configurable pulses on the LED pin, PA5, which is "D13" on the Arduino connector

Reads input pulses on PA8, which is "D7" on the Arduino connector

Register map is documented at register_map

Definition in file stm32f091nucleo64_pulser.c.

Macro Definition Documentation

◆ AF_TIM_LED

#define AF_TIM_LED   GPIO_AF2

Definition at line 43 of file stm32f091nucleo64_pulser.c.

◆ ASC_USART

#define ASC_USART   USART2

Definition at line 35 of file stm32f091nucleo64_pulser.c.

◆ ASC_USART_NO

#define ASC_USART_NO   2

Definition at line 34 of file stm32f091nucleo64_pulser.c.

◆ IC_AF

#define IC_AF   GPIO_AF2

Definition at line 57 of file stm32f091nucleo64_pulser.c.

◆ IC_PIN

#define IC_PIN   GPIO8

Definition at line 52 of file stm32f091nucleo64_pulser.c.

◆ IC_PORT

#define IC_PORT   GPIOA

Definition at line 51 of file stm32f091nucleo64_pulser.c.

◆ IC_RCC_GPIO

#define IC_RCC_GPIO   RCC_GPIOA

Definition at line 53 of file stm32f091nucleo64_pulser.c.

◆ IC_RCC_TIM

#define IC_RCC_TIM   RCC_TIM1

Definition at line 55 of file stm32f091nucleo64_pulser.c.

◆ IC_TI

#define IC_TI   TIM_IC_IN_TI1

Definition at line 56 of file stm32f091nucleo64_pulser.c.

◆ IC_TIM

#define IC_TIM   TIM1

Definition at line 54 of file stm32f091nucleo64_pulser.c.

◆ nRegs

#define nRegs   10

Definition at line 73 of file stm32f091nucleo64_pulser.c.

◆ PIN_LED

#define PIN_LED   GPIO5

Definition at line 38 of file stm32f091nucleo64_pulser.c.

◆ PORT_LED

#define PORT_LED   GPIOA

Definition at line 37 of file stm32f091nucleo64_pulser.c.

◆ pulser_period

#define pulser_period   1000

Definition at line 47 of file stm32f091nucleo64_pulser.c.

◆ pulser_tick_freq

#define pulser_tick_freq   1000

Definition at line 46 of file stm32f091nucleo64_pulser.c.

◆ pulser_width

#define pulser_width   500

Definition at line 48 of file stm32f091nucleo64_pulser.c.

◆ RCC_GPIO_LED

#define RCC_GPIO_LED   RCC_GPIOA

Definition at line 39 of file stm32f091nucleo64_pulser.c.

◆ RCC_TIM_LED

#define RCC_TIM_LED   RCC_TIM2

Definition at line 42 of file stm32f091nucleo64_pulser.c.

◆ TIM_LED

#define TIM_LED   TIM2

Definition at line 40 of file stm32f091nucleo64_pulser.c.

◆ TIM_OC_LED

#define TIM_OC_LED   TIM_OC1

Definition at line 41 of file stm32f091nucleo64_pulser.c.

Function Documentation

◆ DECLARE_ASC_DEVICE_W_REGISTER_POINTERS()

DECLARE_ASC_DEVICE_W_REGISTER_POINTERS ( )
pure virtual

Definition at line 155 of file stm32f091nucleo64_adc_streaming.c.

◆ main()

int main ( void )

Definition at line 131 of file stm32f091nucleo64_pulser.c.

Variable Documentation

◆ e

CEXCEPTION_T e

Definition at line 64 of file stm32f091nucleo64_pulser.c.

◆ ic_overrun

uint32_t ic_overrun

Definition at line 60 of file stm32f091nucleo64_pulser.c.

◆ ic_period

uint32_t ic_period

Definition at line 59 of file stm32f091nucleo64_pulser.c.

◆ ic_pulse_length

uint32_t ic_pulse_length

Definition at line 58 of file stm32f091nucleo64_pulser.c.

◆ MILLISEC_TIMER_SYSTICK_IT

MILLISEC_TIMER_SYSTICK_IT

Definition at line 67 of file stm32f091nucleo64_pulser.c.

◆ nExceptions

uint16_t nExceptions

Definition at line 65 of file stm32f091nucleo64_pulser.c.

◆ optionFlags

uint32_t optionFlags = 0

Definition at line 71 of file stm32f091nucleo64_pulser.c.

◆ register_map

volatile REGTYPE* register_map[nRegs]
Initial value:
= {
&GPIOA_IDR,
&GPIOA_ODR,
&optionFlags,
&TIM_PSC(TIM_LED),
&TIM_ARR(TIM_LED),
&TIM_CCR1(TIM_LED),
&ic_period,
&ic_pulse_length,
&ic_overrun,
}
static uint32_t MILLISEC_TIMER_NOW
A counter that increments every millisecond.

Register Map.

Register Map

Register Number Description r/w
0 PORTA input data register, bit 5 is LED r
1 PORTA output data register, bit 5 is LED r, bit 5 is w
2 optionFlags: see below r/w
3 Current millisecond_timer value r
4 LED pulser prescaler r/w 16 bits
5 LED pulser period r/w 16 bits
6 LED pulser pulse length r/w 16 bits
7 Input capture pulse period r
8 Input capture pulse width r
9 Input capture overrun flags (bit 0 for period and 4 for width) r
See also
register_write_masks

Definition at line 95 of file stm32f091nucleo64_pulser.c.

◆ register_write_masks

REGTYPE register_write_masks[nRegs]
Initial value:
= {
0,
1 << 5,
0xFFFFFFFF,
0,
0xFFFF,
0xFFFF,
0xFFFF,
0,
0,
0,
}

Write masks for register_map.

These define whether the given register in register_map is writable or not

Definition at line 113 of file stm32f091nucleo64_pulser.c.