-
Notifications
You must be signed in to change notification settings - Fork 0
/
sfcn_PWM_Out_wrapper.c
92 lines (82 loc) · 2.54 KB
/
sfcn_PWM_Out_wrapper.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
* Include Files
*
*/
#if defined(MATLAB_MEX_FILE)
#include "tmwtypes.h"
#include "simstruc_types.h"
#else
#include "rtwtypes.h"
#endif
/* %%%-SFUNWIZ_wrapper_includes_Changes_BEGIN --- EDIT HERE TO _END */
# ifndef MATLAB_MEX_FILE
#include </home/pi/wiringPi/devLib/gertboard.h>
#include </home/pi/wiringPi/devLib/piNes.h>
#include </home/pi/wiringPi/wiringPi/softServo.h>
#include </home/pi/wiringPi/wiringPi/wiringSerial.h>
#include </home/pi/wiringPi/wiringPi/wiringPiI2C.h>
#include </home/pi/wiringPi/wiringPi/wiringShift.h>
#include </home/pi/wiringPi/wiringPi/softPwm.h>
#include </home/pi/wiringPi/wiringPi/wiringPi.h>
#include </home/pi/wiringPi/wiringPi/wiringPiSPI.h>
#include </home/pi/wiringPi/wiringPi/softTone.h>
// for digital out:
#include </home/pi/wiringPi/wiringPi/wiringPi.c>
#include </home/pi/wiringPi/wiringPi/piHiPri.c>
#include </home/pi/wiringPi/wiringPi/softPwm.c>
// for pwm:
#include </home/pi/wiringPi/wiringPi/piThread.c>
#include </home/pi/wiringPi/wiringPi/softTone.c>
# endif
/* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */
#define u_width 1
#define y_width
/*
* Create external references here.
*
*/
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
/* extern double func(double a); */
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
/*
* Output functions
*
*/
void sfcn_PWM_Out_Outputs_wrapper(const uint8_T *in,
const real_T *xD,
const uint8_T *pin, const int_T p_width0)
{
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
/* wait until after initialization is done */
if (xD[0]==1) {
/* don't do anything for mex file generation */
# ifndef MATLAB_MEX_FILE
// Update Output:
softPwmWrite (pin[0],in[0]) ;
# endif
}
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
}
/*
* Updates function
*
*/
void sfcn_PWM_Out_Update_wrapper(const uint8_T *in,
real_T *xD,
const uint8_T *pin, const int_T p_width0)
{
/* %%%-SFUNWIZ_wrapper_Update_Changes_BEGIN --- EDIT HERE TO _END */
if (xD[0]!=1) {
/* don't do anything for MEX-file generation */
# ifndef MATLAB_MEX_FILE
// Initialize WiringPi
wiringPiSetup ();
// Initialize pin as output
// In WiringPi pins are not GPIO pins see "WiringPi GPIO Pins"
softPwmCreate (pin[0], 0, 255) ;
# endif
/* initialization done */
xD[0]=1;
}
/* %%%-SFUNWIZ_wrapper_Update_Changes_END --- EDIT HERE TO _BEGIN */
}