Adaptation K22F

Dependencies:   mbed

Committer:
singularity
Date:
Tue Dec 16 15:52:17 2014 +0000
Revision:
0:6004a7230f87
Creation k22F

Who changed what in which revision?

UserRevisionLine numberNew contents of line
singularity 0:6004a7230f87 1 #include "Camera.h"
singularity 0:6004a7230f87 2
singularity 0:6004a7230f87 3
singularity 0:6004a7230f87 4 Camera::Camera(PinName pin_si, PinName pin_clk, PinName pin_ao, int periode_us) : ao(pin_ao),si(pin_si),clk(pin_clk)
singularity 0:6004a7230f87 5 {
singularity 0:6004a7230f87 6 this->periode = periode_us;
singularity 0:6004a7230f87 7 }
singularity 0:6004a7230f87 8
singularity 0:6004a7230f87 9 /*Quelques infos
singularity 0:6004a7230f87 10 Voir la doc de la cam
singularity 0:6004a7230f87 11 On genere une impulsion sur SI pour terminer l'acquisition en cours et signaler que l'on va lire les valeurs des pixels
singularity 0:6004a7230f87 12 La valeur d'un pixel est mis analogiquement sur AO apres chaque front montant d'horloge
singularity 0:6004a7230f87 13 SI et clk sont en quadratures de phase
singularity 0:6004a7230f87 14 Le temps d'intégration est le temps entre la lecture du 28 eme pixel et le prochain signal SI*/
singularity 0:6004a7230f87 15 void Camera::capture(unsigned short *valeurs)
singularity 0:6004a7230f87 16 {
singularity 0:6004a7230f87 17 //ENVOI DU SIGNAL DE START SUR SI(QUADRATURE DE PHASE AVEC CLK)
singularity 0:6004a7230f87 18 this->si.write(1);
singularity 0:6004a7230f87 19 wait_us(this->periode);
singularity 0:6004a7230f87 20 this->clk.write(1);
singularity 0:6004a7230f87 21 wait_us(this->periode);
singularity 0:6004a7230f87 22 this->si.write(0);
singularity 0:6004a7230f87 23 wait_us(this->periode);
singularity 0:6004a7230f87 24 this->ao.read_u16();
singularity 0:6004a7230f87 25 this->clk.write(0);
singularity 0:6004a7230f87 26
singularity 0:6004a7230f87 27 //RECUPERATION DES DONNEES
singularity 0:6004a7230f87 28 wait_us(this->periode);
singularity 0:6004a7230f87 29 for (int i = 0; i < 128; i++)
singularity 0:6004a7230f87 30 {
singularity 0:6004a7230f87 31 wait_us(this->periode);
singularity 0:6004a7230f87 32 wait_us(this->periode);
singularity 0:6004a7230f87 33 this->clk.write(1);
singularity 0:6004a7230f87 34 wait_us(this->periode);
singularity 0:6004a7230f87 35 wait_us(this->periode);
singularity 0:6004a7230f87 36 //this->ao.read(); pour avoir des flottants sur [0;1]
singularity 0:6004a7230f87 37 valeurs[i] = this->ao.read_u16();
singularity 0:6004a7230f87 38 this->clk.write(0);
singularity 0:6004a7230f87 39 }
singularity 0:6004a7230f87 40
singularity 0:6004a7230f87 41 //PROCEDURE DE TERMINAISON
singularity 0:6004a7230f87 42 wait_us(this->periode);
singularity 0:6004a7230f87 43 wait_us(this->periode);
singularity 0:6004a7230f87 44 this->clk.write(1);
singularity 0:6004a7230f87 45 wait_us(this->periode);
singularity 0:6004a7230f87 46 wait_us(this->periode);
singularity 0:6004a7230f87 47 this->clk.write(0);
singularity 0:6004a7230f87 48
singularity 0:6004a7230f87 49 }
singularity 0:6004a7230f87 50
singularity 0:6004a7230f87 51 void Camera::setPeriod(int periode)
singularity 0:6004a7230f87 52 {
singularity 0:6004a7230f87 53 this->periode = periode;
singularity 0:6004a7230f87 54 }