I'm writing library for smart home arduino DIY project.
i want to use another library(not written by me).
here is the code:
boiler.cpp
#include "Boiler.h"
Boiler::Boiler(int pin)
{
_pin = pin;
dev.setDevice(_pin); // Set Device Output (on/off)
turnOff();
}
boiler.h
#ifndef BOILER_H_
#define BOILER_H_
// include RF24 libs
#include "RF24.h"
#include "RF24Network.h"
#include "RF24Mesh.h"
#include <SPI.h>
// SmartHome Lib Includes
#include "Device.h"
#include "TimerOne.h"
#include "timeSet.h"
class Boiler
{
private:
RF24 radio(7, 8);
RF24Network network(radio);
RF24Mesh mesh(radio, network);
int _pin ;
void timerIsr();
void DrawSCR();
public:
.
.
.
Boiler (int pin );
void turnOn();
void turnOff();
};
The problem is it's not compiling
the error I get is :
Boiler.h: 32:14: error: expected identifier before numeric constant
RF24 radio(7, 8)
What am i doing wrong?
Thanks,
I Have found the answer (by mistake)
i have added the includes to Boiler.cpp file
and moved the
RF24 radio(7, 8); // Init RF24 Radio
RF24Network network(radio); // Init RF24 Network
RF24Mesh mesh(radio, network); // Init RF24 Mesh
this is the new code :
#include "RF24.h"
#include "RF24Network.h"
#include "RF24Mesh.h"
#include <SPI.h>
.
.
.
#include "Boiler.h"
RF24 radio(7, 8); // Init RF24 Radio
RF24Network network(radio); // Init RF24 Network
RF24Mesh mesh(radio, network); // Init RF24 Mesh
Boiler::Boiler(int pin ,float Rev , String Last )
{
_pin = pin;
dev.setDevice(_pin); // Set Device Output (on/off)
turnOff();
}
void Boiler::init( char nodeID)
{
_nodeID = nodeID;
// Connect to the mesh and set Node ID
mesh.setNodeID(_nodeID);
if (_DEBUG) Serial.println(F("Connecting to the mesh..."));
mesh.begin();
// init LCD and print init data on LCD
myGLCD.InitLCD(60); // Init LCD 55 contrast
myGLCD.setFont(SmallFont); // Set small font
myGLCD.clrScr(); // clr screen
myGLCD.print("Boiler Device",0,0); //Print init Data on screen
myGLCD.print("Rev :" , 0 , 10);
myGLCD.printNumF(_rev,1 ,35,10,'.',1,'0');
myGLCD.print(_last,0,40);
myGLCD.update(); // Update display
turnOff();
}
and now it compiles ;-)
Related
I have my arduino libraries folder which holds one library called DHT_sensor_Library. In this folder, I have another folder called DHT_U. In this folder, I have DHT_U.ccp and DHT_U.h.
The problem is that when I include DHT_U.h in my arduino IDE:
#include "DHT_U.h"
The error says:
Tempreture_Humidity_Sensor:2:19: error: DHT_U.h: No such file or directory
compilation terminated.
exit status 1
DHT_U.h: No such file or directory
I have already tried
#include "DHT_U/DHT_U.h" ,
#include "DHT_U\DHT_U.h"
and
#include ..\DHT_U.h". None of these worked.
This is a snippet of my code:
#include "DHT.h"
#include "DHT_U.h"
#include "LiquidCrystal.h"
#include "DHT.h"
Full code can be shown here:
#include <DHT.h>
#include <DHT_U.h>
// include the library code:
#include <LiquidCrystal.h>
#include "DHT.h"
// set the DHT Pin
#define DHTPIN 8
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
dht.begin();
// Print a message to the LCD.
lcd.print("Temp: Humidity:");
}
void loop() {
delay(500);
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// read humidity
float h = dht.readHumidity();
//read temperature in Fahrenheit
float f = dht.readTemperature(true);
if (isnan(h) || isnan(f)) {
lcd.print("ERROR");
return;
}
lcd.print(f);
lcd.setCursor(7,1);
lcd.print(h);
}
How should I fix this?
Try including the hole path like "/home/your_username/arduino/lib/foo.h" or something like this. Are you sure it is a .h file and not a .hpp ?
One thing to consider is that you need to be careful when your #include methods.
If DHT_U.h is located in the same direction as your .ino file you can include it with this:
#include "DHT_U.h"
However, if you installed the library using the library manager from Arduino IDE, you should do:
#include <DHT_U.h>
If none of these works, make sure that you have installed correctly your library. You could try by testing the examples from the Arduino IDE with the library that you have installed.
It's telling me that "accelerometer" and "lcd" were not declared in this scope when they're used in PIT0_IRQHandler. None of the solutions I've found online have worked as of yet so I figured I'd just post it up. I'm pretty new to this as well so feel free to point out any and every error included
#include <stdio.h>
#include "system.h"
#include "derivative.h"
#include "hardware.h"
#include "delay.h"
#include "lcd.h"
#include "i2c.h"
#include "level.h"
#include "mma845x.h"
#include "tone.h"
#include "accel.h"
/// LCD dimensions and centerpoint
#define LCD_WIDTH (LCD_X_MAX-LCD_X_MIN)
#define LCD_HEIGHT (LCD_Y_MAX-LCD_Y_MIN)
#define CENTRE_X ((LCD_X_MAX-LCD_X_MIN)/2)
#define CENTRE_Y ((LCD_Y_MAX-LCD_Y_MIN)/2)
#define BACKGROUND_COLOUR (RED)
#define FOREGROUND_COLOUR (WHITE)
#define CIRCLE_RADIUS (20)
using namespace USBDM;
void initialisePIT(int channel, uint32_t interval) {
// Enable clock to PIT
SIM->SCGC6 |= SIM_SCGC6_PIT_MASK;
// Enable PIT module
PIT->MCR = PIT_MCR_FRZ_MASK;
// Set reload value
PIT->CHANNEL[channel].LDVAL = interval-1;
// Enable this channel with interrupts
PIT->CHANNEL[channel].TCTRL = PIT_TCTRL_TEN_MASK|PIT_TCTRL_TIE_MASK;
// Enable PITn interrupts in NVIC
NVIC_EnableIRQ((IRQn_Type)(PIT0_IRQn+channel));
// Set arbitrary priority level
NVIC_SetPriority((IRQn_Type)(PIT0_IRQn+channel), 8);
}
void initialiseLCD(){
// Instantiate SPI interface class
Spi *spi = new Spi0();
// Instantiate LCD interface class
Lcd *lcd = new Lcd(spi);
// Clear Background and set to a preset (Set above) colour
lcd->clear(BACKGROUND_COLOUR);
// Draw crosshairs and initial circle on the screen
lcd->drawLine(LCD_WIDTH/2,LCD_WIDTH/2,0,LCD_HEIGHT,BLACK);
lcd->drawLine(0,LCD_WIDTH,LCD_HEIGHT/2,LCD_HEIGHT/2,BLACK);
lcd->drawCircle(CENTRE_X, CENTRE_Y, 20, WHITE);
}
void initialiseAccel()
{
I2c *i2c = new I2c0();
MMA845x *accelerometer = new MMA845x(i2c, MMA845x::ACCEL_2Gmode);
}
void PIT0_IRQHandler(void) {
int accelStatus;
int16_t accelX,accelY,accelZ;
accelerometer->readAccelerometerXYZ(&accelStatus, &accelX, &accelY, &accelZ);
lcd->clear(BACKGROUND_COLOUR);
lcd->drawCircle(accelX,accelY,20,WHITE);
// Clear the interrupt request from PIT
PIT->CHANNEL[0].TFLG = PIT_TFLG_TIF_MASK;
}
accelerometer is declared in initialiseAccel. It will go out of scope at the end of that function, and is not a known name in PIT0_IRQHandler. You should probably create a class to hold those variables and functions, or you'll have to use global variables (possibly in a namespace) to hold those values.
I have to code a the library motorIR, which uses NECIRrcv to extract the IR code from a sensor.
Initially I tried doing it using two libraries, but that doesn't seem to be easy as I read, so I decide to include both the header and the source file of NECIRrcv in my Arduino library motorIR.
I'm having some trouble with defining NECIRrcv sensor in motorIR.
If I do it where it's placed in the code, no signal is available (while(sensor.available())is never entered).
I can understand that's logical, since it redefines sensor every time I call motorIR::control().
My real problem is that I have no clue of where I should declare sensor, the object of NECIRrcv class, in motorIR.
I did a little research about it, and since I haven't worked with extern classes before, I've ended up even more confused about if using one it's necessary.
I'd be very grateful if someone can invest a few minutes helping me with this subject. Hope you can understand my explanations.
Here you are the different files:
File motorIR.h
#ifndef motorIR_h
#define motorIR_h
#include "Arduino.h"
#include "NECIRrcv.h"
#define STANDBY 999
#define inputIR 2
#define PWM_1 3
#define MI_1 4
#define MD_1 5
#define PWM_2 6
#define MI_2 7
#define MD_2 8
#define FORWARD
#define BACKWARD
class motorIR
{
public: // Funciones públicas
motorIR(int pPWM_1, int pMI_1, int pMD_1, int pPWM_2, int pMI_2, int pMD_2);
void setMotor(int PWM, int MI, int MD);
void begin();
void control();
void translate();
void serialPrint();
private: // Variables privadas
int _PWM= STANDBY;
int _MI;
int _MD;
unsigned long _IRcode;
// static NECIRrcv & getSensor() // <--- getSensor() added
// {
// static NECIRrcv sensor(4);
// return sensor;
// }
// static NECIRrcv & getSensor()
// {
// static NECIRrcv sensor(4);
// static bool firstRun(true);
// if ( firstRun )
// {
// sensor.begin();
// firstRun = false;
// }
// return sensor;
// }
};
#endif
File motorIR.cpp
#include "Arduino.h"
#include "motorIR.h"
#include <string.h>
motorIR::motorIR(int PWM, int MI, int MD) // Constructor
{
_MI= MI +A0;
_PWM= PWM +A0;
_MD= MD +A0;
}
void motorIR::beginner()
{
Serial.begin(9600);
Serial.print("Begin");
}
void motorIR::control(int i)
{
NECIRrcv sensor(4) ; // I doesn't work as expected if placed here
sensor.begin();
Serial.println("Checkpoint");
while (sensor.available())
{
Serial.print("Detection");
IRcode= sensor.read();
Serial.print(IRcode, DEC);
Serial.print(IRcode, HEX);
Serial.print(IRcode, BIN);
}
}
File NECIRrcv.h (given)
#ifndef NECIRrcv_h
#define NECIRrcv_h
#include <Arduino.h>
#include "motorIR.h"
#define USECPERTICK 50 // microseconds per clock interrupt tick
#define CLKFUDGE 5 // fudge factor for clock interrupt overhead
#define CLKMAX 256 // max value for clock (timer 2)
#define PRESCALE 8 // timer2 clock prescale
#define SYSCLOCK 16000000 // main Arduino clock
#define CLKSPERUSEC (SYSCLOCK/PRESCALE/1000000) // timer clocks per microsecond
#define MAXBUF 8 // IR command code buffer length (circular buffer)
// IR detector output is active low
#define MARK 0
#define SPACE 1
#define NBITS 32 // bits in IR code
#define BLINKLED 13
// defines for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
// clock timer reset value
#define INIT_TIMER_COUNT2 (CLKMAX - USECPERTICK*CLKSPERUSEC + CLKFUDGE)
#define RESET_TIMER2 TCNT2 = INIT_TIMER_COUNT2
// pulse parameters -- nominal usec
#define STARTNOM 9000
#define SPACENOM 4500
#define BITMARKNOM 620
#define ONESPACENOM 1600
#define ZEROSPACENOM 480
#define RPTSPACENOM 2180
#define TOLERANCE 20 // percent
#define LTOL (1.0 - TOLERANCE/100.)
#define UTOL (1.0 + TOLERANCE/100.)
// pulse parameters (tick counts)
#define STARTMIN (int)((STARTNOM/USECPERTICK)*LTOL) // start MARK
#define STARTMAX (int)((STARTNOM/USECPERTICK)*UTOL)
#define SPACEMIN (int)((SPACENOM/USECPERTICK)*LTOL)
#define SPACEMAX (int)((SPACENOM/USECPERTICK)*UTOL)
#define BITMARKMIN (int)((BITMARKNOM/USECPERTICK)*LTOL-2) // extra tolerance for low counts
#define BITMARKMAX (int)((BITMARKNOM/USECPERTICK)*UTOL+2)
#define ONESPACEMIN (int)((ONESPACENOM/USECPERTICK)*LTOL)
#define ONESPACEMAX (int)((ONESPACENOM/USECPERTICK)*UTOL)
#define ZEROSPACEMIN (int)((ZEROSPACENOM/USECPERTICK)*LTOL-2)
#define ZEROSPACEMAX (int)((ZEROSPACENOM/USECPERTICK)*UTOL+2)
#define RPTSPACEMIN (int)((RPTSPACENOM/USECPERTICK)*LTOL)
#define RPTSPACEMAX (int)((RPTSPACENOM/USECPERTICK)*UTOL)
// receiver states
#define IDLE 1
#define STARTH 2
#define STARTL 3
#define BIT 4
#define ONE 5
#define ZERO 6
#define STOP 7
#define BITMARK 8
#define RPTMARK 9
// macros
#define GETIR(X) ((byte)digitalRead(X)) // used to read IR pin
#define nextstate(X) (irparams.rcvstate = X)
// state machine variables irparams
static volatile struct {
byte rcvstate ; // IR receiver state
byte bitcounter ; // bit counter
byte irdata ; // MARK or SPACE read from IR input pin
byte fptr ; // irbuf front pointer
byte rptr ; // irbuf rear pointer
byte irpin ; // pin for IR data from detector
byte blinkflag ; // TRUE to enable blinking of pin 13 on IR processing
unsigned int timer ; // state timer
unsigned long irmask ; // one-bit mask for constructing IR code
unsigned long ircode ; // IR code
unsigned long irbuf[MAXBUF] ; // circular buffer for IR codes
} irparams ;
// main class
class NECIRrcv
{
public:
NECIRrcv(int irpin);
unsigned long read();
void begin();
int available() ;
void flush() ;
void blink13(int blinkflag) ;
private:
} ;
extern NECIRrcv sensor; // <-------- declaring object as extern
#endif
File NECIRrcv.cpp (given)
#include <Arduino.h>
#include "NECIRrcv.h"
#include "motorIR.h"
NECIRrcv::NECIRrcv(int irpin)
{
irparams.irpin = irpin ;
}
void NECIRrcv::begin() {
//(...)
}
unsigned long NECIRrcv::read()
{
unsigned long ircode ;
//(...)
return((unsigned long)-1) ;
}
// (...)
Eduardo
If you need only a sensor for all instances of motorIR, I suppose that it could be a static member of the class.
Or a static variable in a static method; like this
class motorIR
{
public: // Funciones públicas
motorIR(int PWM, int MI, int MD);
void beginner();
void control(int i);
private: // Variables privadas
int _PWM= STANDBY;
int _MI;
int _MD;
int pin_IR;
unsigned long IRcode;
static NECIRrcv & getSensor() // <--- getSensor() added
{ static NECIRrsv sensor(4); return sensor; }
};
You can use it in this way
void motorIR::control(int i)
{
// NECIRrcv sensor(4) ; no more here
getSensor().begin();
Serial.println("Checkpoint");
while (getSensor().available())
{
Serial.print("Detection");
IRcode= getSensor().read();
Serial.print(IRcode, DEC);
Serial.print(IRcode, HEX);
Serial.print(IRcode, BIN);
}
}
p.s.: caution: not tested
p.s.2: sorry for my bad English
--- EDIT ---
The error is "'NECIRrcv' does not name a type" or "'NECIRrcs' does not name a type"?
In my example I've written, by mistake "NECIRrcs" instead of "NECIRrcv"; sorry.
About your need to begin() only one time the sensor, you can modify the getSensor() method in this way
static NECIRrcv & getSensor()
{
static NECIRrsv sensor(4);
static bool firstRun(true);
if ( firstRun )
{
sensor.begin();
firstRun = false;
}
return sensor;
}
Caution: not tested.
I loved the idea of declaring the object NECIRrcv::sensor as part of class motorIR though, but trying to define NECIRrcv sensor(4) anywhere in motorIR.h leads to error: 'NECIRrcv' does not name a type; so it would be interesting to solve this problem in order to be able to implement #max66 's idea (or eve just to figure out why motorIR.h doesn't recognize NECIRrcv properly).
In spite of that, I think I've run into an alternative solution: using an extern object (as it's described here).
It can be implemented as it follows:
In NECIRrcv header:
#ifndef NECIRrcv_h
#define NECIRrcv_h
#include <Arduino.h>
// (...)
class NECIRrcv
{
public:
NECIRrcv(int irpin);
// (...)
private:
} ;
extern NECIRrcv sensor; // <-------- declaring object as extern
#endif
In motorIR source file:
#include "Arduino.h"
#include "motorIR.h"
#include <string.h>
NECIRrcv sensor(4); // <--------- defining object
motorIR::motorIR(int PWM, int MI, int MD)
{
_MI= MI +A0;
_PWM= PWM +A0;
_MD= MD +A0;
}
void motorIR::beginner()
{
Serial.begin(9600);
Serial.print("Begin");
sensor.begin(); // <-------- now I can initialize sensor here
}
void motorIR::control(int i)
{
// NECIRrcv sensor(4) ;
// sensor.begin();
Serial.println("Checkpoint");
while (sensor.available()) // <-- method 1
{
Serial.print("Detection");
IRcode= sensor.read(); // <-- method 2
Serial.print(IRcode, DEC);
Serial.print(IRcode, HEX);
Serial.print(IRcode, BIN);
}
}
I am trying to embed a movie in a Qt (4.7.1) widget using ActiveQt:
VideoManager2.h:
#ifndef VIDEOMANAGER2_H_
#define VIDEOMANAGER2_H_
#include <QtCore/QtCore>
#include <QtGui/QtGui>
#include "qaxwidget.h"
class VideoManager2: public QWidget{
Q_OBJECT
//Q_ENUMS(ReadyStateConstants);
enum PlayStateConstants { Stopped = 0, Paused = 1, Playing = 2 };
enum ReadyStateConstants { Uninitialized = 0, Loading = 1, Interactive = 3, Complete = 4 };
QAxWidget *wmp;
private slots:
void onPlayStateChange(int a, int b);
void onReadyStateChange(ReadyStateConstants readyState);
public:
VideoManager2();
};
#endif /* VIDEOMANAGER2_H_ */
VideoManager2.cpp:
#include <QtCore/QtCore>
#include <QtGui/QtGui>
#include <InitGuid.h>
#include "VideoManager2.h"
#include "wmp.h"
#include "qaxobject.h"
VideoManager2::VideoManager2() {
wmp = new QAxWidget(this);
wmp->setControl("{6BF52A52-394A-11D3-B153-00C04F79FAA6}");
wmp->setProperty("ShowControls", false);
wmp->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
wmp->setProperty("URL", "C:/Users/qxf3567/Downloads/demoMedia/movie/earth.avi");
qDebug("Version Info: %s", qPrintable(wmp->property("versionInfo").toString()));
qDebug("Playing: %s", qPrintable(wmp->property("URL").toString()));
qDebug("State: %s", qPrintable(wmp->property("playState").toString()));
QAxObject* currentMedia= wmp->querySubObject("currentMedia");
IWMPMedia *media;
currentMedia->queryInterface(QUuid(__uuidof(IWMPMedia)), (void **)&media);
{
BSTR durationStr;
media->get_durationString(&durationStr);
QString convertedBSTR((QChar*) durationStr, wcslen(durationStr));
qDebug("Duration: %s", qPrintable(QString(convertedBSTR)));
}
}
void VideoManager2::onPlayStateChange(int a, int b){
}
void VideoManager2::onReadyStateChange(ReadyStateConstants readyState){
}
main.cpp:
...
QScrollArea *movieWidget = new QScrollArea(groupBox_2);
VideoManager2 vm;
ui->movieWidget->setWidget(&vm);
...
Output:
Version Info: 12.0.7601.18741
Playing: C:\Users\qxf3567\Downloads\demoMedia\movie\earth.avi
State: 9
Duration: 00:00
I can get the Version number of WMPlayer, but the movie to be played is displayed as 0 length. What could be the problem here? It's as if it doensn't find the file in the first place?!
I am doing a simple project on arm based mini6410. I have debian package installed on mini. My project is to interface one IR motion sensor and I USB webcam with the mini6410. the working will be simple, whenever there will be any motion detected by IR sensor, the webcam will be on for 30 seconds save the images (over write the previous) and then off.
I have already cross comiled the Open CV code using arm-linux-gcc
For IR I am using GPE register.
Here I am stuck with a issue which I am unable to resolve. and even dont know how to resolve. OpenCv code is a cpp file camera.cpp and the file which deals with I/O ports is a C file named sensor.c. Now in that c file I am polling or whatever mechanism to check if the GPE register is 1 or not. If it is one, I should start the Open CV code which will start to capture images. further more this sensor.c file is not to be compiled rather made a module and then insmod on my mini6410.
However I dont know how to write c++ code in a c file. you can say i dont know how to call the OpenCV thing from the C file. as it is a module and within this i cant write the cpp code as then using namespace std and using namespace cv doesnot work.
i am new to embedded stuff and linux it self. so I wanted to know are there some possible solutions.
i am attaching my codes of both files.
This is sensor.c
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/input.h>
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/serio.h>
#include <linux/delay.h>
#include <linux/clk.h>
#include <linux/wait.h>
#include <linux/sched.h>
#include <linux/cdev.h>
#include <linux/miscdevice.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/uaccess.h>
#include <mach/map.h>
#include <mach/regs-clock.h>
#include <mach/regs-gpio.h>
#include <plat/gpio-cfg.h>
#include <mach/gpio-bank-q.h>
#include <mach/gpio-bank-e.h>
#include <mach/map.h>
#include <plat/regs-timer.h>
#include <mach/hardware.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/fs.h>
#include <linux/types.h>
#include <linux/moduleparam.h>
#include <linux/ioctl.h>
#include <linux/cdev.h>
#include <linux/string.h>
#include <linux/list.h>
#include <linux/pci.h>
#include <asm/uaccess.h>
#include <asm/atomic.h>
#include <asm/unistd.h>
#include <mach/gpio-bank-k.h>
#define RLV 0x0FFF
unsigned Gpe;
unsigned sensor_value;
typedef struct
{
int delay;
} TIM_DEV;
static TIM_DEV TimDev;
static irqreturn_t INTHandler(int irq,void *TimDev)
{
Gpe = readl(S3C64XX_GPEDAT);
Gpe &= ~(0xF<<1);
readl(sensor_value, S3C64XX_GPEDAT);
while (sensor_value == 1)
{//1 means that IR sensor has detected a motion and given a value of +5 V
for (i = 0; i < 30; i++){
//CV_function();
// delay here such that delay(1 s) * 30 = 30 seconds
}
}
return IRQ_HANDLED;
}
static struct file_operations dev_fops = {
.owner = THIS_MODULE,
.write = MyWrite,
};
static struct miscdevice misc = {
.minor = MISC_DYNAMIC_MINOR,
.name = DEVICE_NAME,
.fops = &dev_fops,
};
static int __init dev_init(void)
{
int ret;
unsigned TimerControl;
unsigned TimerINTControl;
unsigned TimerCNTB;
unsigned TimerCMPB;
unsigned TimerCFG1;
unsigned Ge;
TimerControl = readl(S3C_TCON);
TimerINTControl = readl(S3C_TINT_CSTAT);
TimerCNTB = readl(S3C_TCNTB(0));
TimerCMPB = readl(S3C_TCMPB(0));
TimerCFG1 = readl(S3C_TCFG1);
TimerCFG1 &= ~(S3C_TCFG1_MUX0_MASK);
TimerCNTB = RLV;
TimerCMPB = 0;
writel(TimerCNTB, S3C_TCNTB(0));
writel(TimerCMPB, S3C_TCMPB(0));
writel(TimerCFG1, S3C_TCFG1);
TimerControl |= S3C_TCON_T0MANUALUPD;
TimerINTControl |= S3C_TINT_CSTAT_T0INTEN;
writel(TimerControl, S3C_TCON);
writel(TimerINTControl, S3C_TINT_CSTAT);
TimerControl = readl(S3C_TCON);
TimerControl |= S3C_TCON_T0RELOAD;
TimerControl &= ~S3C_TCON_T0MANUALUPD;
TimerControl |= S3C_TCON_T0START;
writel(TimerControl, S3C_TCON);
//////////////Here I am configuring my GPE as input/////////////
Ge = readl(S3C64XX_GPECON);
Ge &= ~(0xFFFF<<4);
Ge |= (0x0000<<4);
writel(Ge, S3C64XX_GPECON);
/////////////
misc_register(&misc);
ret = request_irq(IRQ_TIMER0, INTHandler, IRQF_SHARED, DEVICE_NAME, &TimDev);
if (ret)
{
return ret;
}
return ret;
}
static void __exit dev_exit(void)
{
free_irq(IRQ_TIMER0, &TimDev);
misc_deregister(&misc);
}
module_init(dev_init);
module_exit(dev_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("XYZ");
this is camera.cpp
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <stdio.h>
using namespace std;
using namespace cv;
int main( int argc, const char** argv )
{CvCapture* capture = 0;
Mat frame, frameCopy, image;
capture = cvCaptureFromCAM( 2 );
if( !capture )
{
cout << "No camera detected" << endl;
}
if( capture )
{
cout << "In capture ..." << endl;
IplImage* iplImg = cvQueryFrame( capture );
frame = iplImg;
if( frame.empty() )
break;
if( iplImg->origin == IPL_ORIGIN_TL )
frame.copyTo( frameCopy );
else
flip( frame, frameCopy, 0 );
cvSaveImage("image.jpg" ,iplImg);
}
cvReleaseCapture( &capture );
return 0;
}
the for loop in the sensor.c file should have my this above code by some means
I hope you get the idea,
Thanks
The missing link in the code shown is a mechanism by which the user-space code shown above can get notification of a change in the GPIO pin detected by the device driver.
There are two obvious ways to achieve this:
Integrate the GPIO pin into the platform's GPIO resources and then use the generic sysfs mechanism from user-space. The Linux kernel GPIO documentation describes both kernel and user-space side of this.
Have your driver expose a sysfs node for the GPIO line. sysfs is fundamental to the Linux Driver Model. I suggest a thorough read of Linux Device Drivers 3rd Edition.
The user-space side of either method is similar: You open the sysfs resource exported by your module and then use either poll() or select() to block until an event occurs.