-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathARC_ISR_code.txt
More file actions
50 lines (33 loc) · 1.54 KB
/
ARC_ISR_code.txt
File metadata and controls
50 lines (33 loc) · 1.54 KB
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
import RPi.GPIO as gpio #get GPIO Library
import time #get sleep function to delay loop and possibly detect time
def setup():
gpioPWM(user_gpio,255) #sets GPIO user_gpio full on
gpioSetmode(GPIO.BOARD) #Use Raspberry Pi Board Pin Numbers
gpioSetMode(11,PI.OUTPUT) #Set pin 11 as output
gpioSetMode(7,PI.INPUT) #Set pin 7 as input
if __name__ == '__main__':
pgioInitialise() #Must be called before all other lib funcs
#somehow set up global variable to keep count of time in ms when this function is called
gpioSetISRFunc(GPIOnum, RISING_EDGE, 1, ISR); //calls ISR with the variables before it.
#Change gpionum to whatever pgio to refer to, timeout is interrupt timeout
#int gpioSetISRFunc(unsigned gpio, unsigned edge, int timeout, gpioISRFunc_t f)
#Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_EDGE, or PI_BAD_ISR_INIT.
def ISR(int gpio, int level, uint32_t tick):
uint32_t startTick, endTick
int diffTick
if(level == 1)
startTick = gpio.gpioTicks()
elif(level == 2 & startTick!=null)
DiffTick = gpio.gpioTick() - startTick
#global variable assigned by difftick
# Tick is the number of microseconds since system boot.
# As tick is an unsigned 32 bit quantity it wraps around after
# 2^32 microseconds, which is approximately 1 hour 12 minutes.
#Do something with gpioGetPWMDutycycle(user_pgio)
dutycycle = gpioGetPWMDutycycle(user_pgio)
#do you want to pgioSetPWMrange(pgio,range)? (norm is 255)
//Type 3 Model Pi3B
#ignore
#include <stdio.h>
#include <pigpio.h>
https://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/