diff options
author | siddhu8990 | 2016-08-18 15:47:18 +0530 |
---|---|---|
committer | siddhu8990 | 2016-08-18 15:47:18 +0530 |
commit | 1552675d4ac3be8d265bcf089fbc1ac5be1547f9 (patch) | |
tree | 4162a70fa63681584c6d5485b08b516e64015569 /2.3-1/src/c/hardware/rasberrypi/pwm | |
parent | 21ab4886b202a52189b398bd9d3137e2a567d62a (diff) | |
download | Scilab2C-1552675d4ac3be8d265bcf089fbc1ac5be1547f9.tar.gz Scilab2C-1552675d4ac3be8d265bcf089fbc1ac5be1547f9.tar.bz2 Scilab2C-1552675d4ac3be8d265bcf089fbc1ac5be1547f9.zip |
RPi-PWM and basic imaage processing
Diffstat (limited to '2.3-1/src/c/hardware/rasberrypi/pwm')
4 files changed, 106 insertions, 0 deletions
diff --git a/2.3-1/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMSetClocks.c b/2.3-1/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMSetClocks.c new file mode 100644 index 00000000..883f3faf --- /dev/null +++ b/2.3-1/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMSetClocks.c @@ -0,0 +1,27 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +/*Function to set clock for pwm channel. Default clock is 19.2 MHz. 'clk_divisor' + along with range decides frequency for PWM + PWM frequency = 19.2 MHz / clk_divisor/ range + Range for clk_divisor = 1-2048 + */ + +#include "types.h" +#include "RPIPeripheralPWM.h" + +uint8 u8RPIHardPWMSetClocks(uint16 clk_divisor) +{ + pwmSetClock(clk_divisor); + + return 0; +} diff --git a/2.3-1/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMSetModes.c b/2.3-1/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMSetModes.c new file mode 100644 index 00000000..5a7ccd15 --- /dev/null +++ b/2.3-1/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMSetModes.c @@ -0,0 +1,28 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +/*Function to set mode for PWM channel. Two modes are available + 0 --> balanced mode + 1 --> mark/space mode + */ + +#include "types.h" +#include "RPIPeripheralPWM.h" + +uint8 u8RPIHardPWMSetModes(uint8 mode) +{ + if (mode == 1) /*mark/space mode*/ + pwmSetMode(PWM_MODE_MS); + else + pwmSetMode(PWM_MODE_BAL); + return 0; +} diff --git a/2.3-1/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMSetRanges.c b/2.3-1/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMSetRanges.c new file mode 100644 index 00000000..e3cda77e --- /dev/null +++ b/2.3-1/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMSetRanges.c @@ -0,0 +1,25 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +/*Function to assigne pwm duty to specified pin. PWM duty is decided by 'value' + and 'range' specified using corresponding function. + PWM duty = value/range + */ + +#include "types.h" +#include "RPIPeripheralPWM.h" + +uint8 u8RPIHardPWMSetRanges(uint16 value) +{ + pwmSetRange(value); + return 0; +} diff --git a/2.3-1/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMWrites.c b/2.3-1/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMWrites.c new file mode 100644 index 00000000..546cfd5f --- /dev/null +++ b/2.3-1/src/c/hardware/rasberrypi/pwm/u8RPIHardPWMWrites.c @@ -0,0 +1,26 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Siddhesh Wani + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +/*Function to set range for pwm channel. PWM duty is decided by 'range' + and 'value' specified using corresponding function. + PWM duty = value/range + */ + +#include "types.h" +#include "RPIPeripheralPWM.h" +#include "RPIPeripheralDigital.h" + +uint8 u8RPIHardPWMWrites(uint8 pin, uint16 value) +{ + pwmWrite((int)phy_pin[pin-1], value); + return 0; +} |