OK, it builds now
parent
12a52dfc5d
commit
5e57557444
|
@ -1,6 +1,7 @@
|
|||
project('timdac', 'c', default_options: ['default_library=static'])
|
||||
|
||||
o_hw = get_option('timdac_hw')
|
||||
o_config = get_option('timdac_config')
|
||||
|
||||
sources = ['src/timdac.c', 'src/timdac_ll.c']
|
||||
dependencies = []
|
||||
|
@ -15,9 +16,17 @@ endif
|
|||
|
||||
add_project_arguments(defs, language: ['c', 'cpp'])
|
||||
|
||||
config_h = custom_target(
|
||||
'timdac_config.h',
|
||||
command: [find_program('echo'), o_config],
|
||||
capture: true,
|
||||
output: 'timdac_config.h',
|
||||
)
|
||||
|
||||
timdac_lib = library(
|
||||
'timdac',
|
||||
sources,
|
||||
config_h,
|
||||
dependencies: dependencies,
|
||||
include_directories: ['src'],
|
||||
)
|
||||
|
|
|
@ -3,3 +3,7 @@ option(
|
|||
description: 'Which hardware driver to use',
|
||||
)
|
||||
|
||||
option(
|
||||
'timdac_config', type: 'string',
|
||||
description: 'Contents of timdac_config.h',
|
||||
)
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
// intellectual property is bullshit bgdc
|
||||
|
||||
#ifndef TIMDAC_CONFIG_H
|
||||
#define TIMDAC_CONFIG_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#define TIMDAC_N_CHANNELS 4
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// HARDWARE DRIVER CONFIGURATION - These may differ between hardware drivers,
|
||||
// check the documentation in yours.
|
||||
|
||||
// CH32V103 timer, must be a general-purpose timer
|
||||
#define TIMDAC_HW_TIMER TIM3
|
||||
|
||||
// CH32V103 output compare channel
|
||||
#define TIMDAC_HW_TIMER_CHANNEL 1
|
||||
|
||||
// CH32V103 timer interrupt. Optional, if you don't define this you must poll.
|
||||
#define TIMDAC_HW_TIMER_IRQn TIM3_IRQn
|
||||
// CH32V103 timer interrupt preemption priority
|
||||
#define TIMDAC_HW_TIMER_IRQPRIO 3
|
||||
// CH32V103 timer interrupt subpriority
|
||||
#define TIMDAC_HW_TIMER_IRQSUBPRIO 3
|
||||
|
||||
// CH32V103 GPIO and pin: timer output compare
|
||||
// You are responsible for making sure this and TIMDAC_HW_TIMER_CHANNEL match
|
||||
// up, and also for applying any GPIO_PinRemapConfig() and clock startup as
|
||||
// necessary prior to initializing timdac.
|
||||
#define TIMDAC_HW_GPIO_TIMER GPIOC, GPIO_Pin_6
|
||||
|
||||
// CH32V103 GPIO and pin: mux inhibit
|
||||
#define TIMDAC_HW_GPIO_MUXINHIBIT GPIOC, GPIO_Pin_3
|
||||
|
||||
// CH32V103 GPIO and pin: integrator discharge
|
||||
#define TIMDAC_HW_GPIO_DISCHARGE GPIOC, GPIO_Pin_5
|
||||
|
||||
// CH32V103 GPIO and pin: polarity
|
||||
// OPTIONAL, do not define if polarity switch is not implemented
|
||||
#define TIMDAC_HW_GPIO_POLARITY GPIOC, GPIO_Pin_4
|
||||
|
||||
// CH32V103 GPIO and pin: tuning comparator
|
||||
#define TIMDAC_HW_GPIO_TUNE GPIOC, GPIO_Pin_7
|
||||
|
||||
// CH32V103 tuning comparator polarity, true = noninverting
|
||||
#define TIMDAC_HW_GPIO_TUNE_POL false
|
||||
|
||||
// CH32V103 GPIO: channel select. All channel select pins must be on the same
|
||||
// port
|
||||
#define TIMDAC_HW_GPIO_CHAN_PORT GPIOC
|
||||
|
||||
// CH32V103 pins: channel select. Start from the LSB, omit or zero unused
|
||||
// bits. Up to 8 bits.
|
||||
#define TIMDAC_HW_GPIO_CHAN_PINS GPIO_Pin_0, GPIO_Pin_1, GPIO_Pin_2
|
||||
|
||||
#define TIMDAC_TIMERFREQ_HZ 72000000
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// TIMDAC CONFIGURATION
|
||||
|
||||
#include "timdac_config_ref1p0.h"
|
||||
|
||||
#endif // !defined(TIMDAC_CONFIG_H)
|
|
@ -32,7 +32,7 @@
|
|||
#define TIMDAC_NRC(n, r, c) ({ \
|
||||
_Static_assert((n) * (r) * (c) * TIMDAC_TIMERFREQ_HZ <= 65535, \
|
||||
"Time constant too high for 16-bit timer"); \
|
||||
(unsigned)(((n) * (r) * (c) * TIMDAC_TIMERFREQ_HZ)) })
|
||||
(unsigned)(((n) * (r) * (c) * TIMDAC_TIMERFREQ_HZ)); })
|
||||
#else
|
||||
#define TIMDAC_NRC(n, r, c) ((unsigned)((n) * (r) * (c) * TIMDAC_TIMERFREQ_HZ))
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue