PICSimLab - Programmable IC Simulator Laboratory 0.9.2
PICSimLab - API
Loading...
Searching...
No Matches
bitbang_pwm.h
1/* ########################################################################
2
3 PICSimLab - Programmable IC Simulator Laboratory
4
5 ########################################################################
6
7 Copyright (c) : 2023-2025 Luis Claudio GambĂ´a Lopes <lcgamboa@yahoo.com>
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
23 For e-mail suggestions : lcgamboa@yahoo.com
24 ######################################################################## */
25
26#ifndef BITBANG_PWM
27#define BITBANG_PWM
28
29class board;
30
31#define PWM_CHANNEL_MAX 32
32
33typedef struct {
34 int TimerID;
35 unsigned int counter;
36 unsigned char pin;
37 unsigned char out;
38 unsigned char duty;
39 unsigned char enabled;
40 unsigned int freq;
41 unsigned int res;
43
44typedef struct {
45 unsigned char channels_count;
46 board* pboard;
47 channel_pwm_t channels[PWM_CHANNEL_MAX];
49
50void bitbang_pwm_init(bitbang_pwm_t* pwm, board* pboard, const unsigned char channels = 8);
51void bitbang_pwm_rst(bitbang_pwm_t* pwm);
52void bitbang_pwm_end(bitbang_pwm_t* pwm);
53void bitbang_pwm_set_duty(bitbang_pwm_t* pwm, const unsigned char channel, const char duty);
54void bitbang_pwm_set_duty_f(bitbang_pwm_t* pwm, const unsigned char channel, const float duty);
55void bitbang_pwm_set_pin(bitbang_pwm_t* pwm, const unsigned char channel, const char pin);
56void bitbang_pwm_set_freq(bitbang_pwm_t* pwm, const unsigned char channel, unsigned int freq);
57void bitbang_pwm_set_enable(bitbang_pwm_t* pwm, const unsigned char channel, unsigned char enable);
58
59#endif // BITBANG_PWM
Board class.
Definition board.h:114
Definition bitbang_pwm.h:44
Definition bitbang_pwm.h:33