8 #include <linux/spi/spidev.h> 16 #include <sys/types.h> 19 using namespace Linux;
21 #define PWM_CHAN_COUNT 8 22 #define RCOUT_ZYNQ_PWM_BASE 0x43c00000 23 #define PWM_CMD_CONFIG 0 24 #define PWM_CMD_ENABLE 1 25 #define PWM_CMD_DISABLE 2 26 #define PWM_CMD_MODIFY 3 29 #define PWM_CMD_TEST 6 40 mem_fd =
open(
"/dev/mem", O_RDWR|O_SYNC|O_CLOEXEC);
53 unsigned long tick=
TICK_PER_S/(
unsigned long)freq_hz;
56 if (chmask & (1U<<i)) {
#define RCOUT_ZYNQ_PWM_BASE
void set_freq(uint32_t chmask, uint16_t freq_hz)
int open(const char *pathname, int flags)
POSIX Open a file with integer mode flags.
void enable_ch(uint8_t ch)
void write(uint8_t ch, uint16_t period_us)
static const int TICK_PER_S
int close(int fileno)
POSIX Close a file with fileno handel.
uint16_t get_freq(uint8_t ch)
static const int TICK_PER_US
struct s_period_hi periodhi[MAX_ZYNQ_PWMS]
void disable_ch(uint8_t ch)
static void catch_sigbus(int sig)
volatile struct pwm_cmd * sharedMem_cmd
uint16_t read(uint8_t ch)
void panic(const char *errormsg,...) FMT_PRINTF(1
uint16_t pending[MAX_ZYNQ_PWMS]