Alexandre Salconi-Denis
/
ProjetOctopode
Programme de contrôle de l'octopode 4DOF, Theraphosa-Salconi.
CtrlBridge
- fonction quelquonque pour communiquer avec les module
- fonction quelquonque pour faire des recherche dans les module dispo
- autre fonction pour jouer avec MemRegistre
Version 1.2.0
- Ajout d'un mode de simulation pour tester le code avec seulement un contrôleur stm32
source/CtrlBridge.h@28:ac5c6350ed9a, 2015-07-28 (annotated)
- Committer:
- salco
- Date:
- Tue Jul 28 01:22:16 2015 +0000
- Revision:
- 28:ac5c6350ed9a
- Parent:
- 17:095f670f9c14
- Child:
- 36:474d4795aafa
tsest
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
salco | 2:4c5b0f6d0a6b | 1 | /** |
salco | 2:4c5b0f6d0a6b | 2 | * @file TTask.h |
salco | 2:4c5b0f6d0a6b | 3 | * @brief Cette classe est le modele des 3 taches de controle. |
salco | 2:4c5b0f6d0a6b | 4 | * @author Salco |
salco | 2:4c5b0f6d0a6b | 5 | * @version 2.00 |
salco | 2:4c5b0f6d0a6b | 6 | * @date 11 mars 2015 |
salco | 2:4c5b0f6d0a6b | 7 | */ |
salco | 2:4c5b0f6d0a6b | 8 | #ifndef CTRLBRIDGE_H |
salco | 2:4c5b0f6d0a6b | 9 | #define CTRLBRIDGE_H |
salco | 7:dcfd81d7f93f | 10 | |
salco | 28:ac5c6350ed9a | 11 | #define DEBUG_INITMODULE /*1*/0 |
salco | 28:ac5c6350ed9a | 12 | #define DEBUF_FINDMODULE 0 |
salco | 28:ac5c6350ed9a | 13 | #define DEBUF_SEND /*1*/0 |
salco | 14:ca1a9230ba7f | 14 | |
salco | 8:e017e3d527d7 | 15 | #define SPI_HIGH_MISO PB_14 |
salco | 8:e017e3d527d7 | 16 | #define SPI_HIGH_MOSI PB_15 |
salco | 11:496453b45e25 | 17 | #define SPI_HIGH_SCK PB_13 |
salco | 15:91b3c572d9df | 18 | #define SPI_HIGH_CS A1 |
salco | 8:e017e3d527d7 | 19 | #define SPI_HIGH_DEMUXA PC_0 |
salco | 8:e017e3d527d7 | 20 | #define SPI_HIGH_DEMUXB PC_1 |
salco | 8:e017e3d527d7 | 21 | #define SPI_HIGH_DEMUXC PC_2 |
salco | 8:e017e3d527d7 | 22 | #define SPI_HIGH_DEMUXD PC_3 |
salco | 8:e017e3d527d7 | 23 | |
salco | 8:e017e3d527d7 | 24 | #define SPI_LOW_MISO PA_6 |
salco | 8:e017e3d527d7 | 25 | #define SPI_LOW_MOSI PA_7 |
salco | 8:e017e3d527d7 | 26 | #define SPI_LOW_SCK PA_5 |
salco | 15:91b3c572d9df | 27 | #define SPI_LOW_CS A0 |
salco | 8:e017e3d527d7 | 28 | #define SPI_LOW_DEMUXA PC_4 |
salco | 8:e017e3d527d7 | 29 | #define SPI_LOW_DEMUXB PC_5 |
salco | 8:e017e3d527d7 | 30 | #define SPI_LOW_DEMUXC PC_6 |
salco | 8:e017e3d527d7 | 31 | #define SPI_LOW_DEMUXD PC_7 |
salco | 8:e017e3d527d7 | 32 | |
salco | 8:e017e3d527d7 | 33 | #include "mbed.h" |
salco | 10:7e6aeaebe1a2 | 34 | #include <string> |
salco | 14:ca1a9230ba7f | 35 | #include "OSNAPprotocoleDefine.h" |
salco | 14:ca1a9230ba7f | 36 | //#include <algorithm> // std::for_each |
salco | 11:496453b45e25 | 37 | #include "debug.h" |
salco | 7:dcfd81d7f93f | 38 | #include "ComSpi.h" //utiliser pour comuniquer avec les module |
salco | 7:dcfd81d7f93f | 39 | #include "MemRegistre.h" //enregistrer les info |
salco | 10:7e6aeaebe1a2 | 40 | #include "Module.h" |
salco | 2:4c5b0f6d0a6b | 41 | class CtrlBridge |
salco | 2:4c5b0f6d0a6b | 42 | { |
salco | 8:e017e3d527d7 | 43 | static CtrlBridge *uniqueInstance; |
salco | 8:e017e3d527d7 | 44 | //pc = new Serial(SERIAL_TX, SERIAL_RX); |
salco | 8:e017e3d527d7 | 45 | //ssc32= new Serial(PA_9, PA_10); |
salco | 7:dcfd81d7f93f | 46 | int m_regPortUse; // set in the init |
salco | 7:dcfd81d7f93f | 47 | int m_regPortLost;// flag 1 si lost |
salco | 9:7295385f02b2 | 48 | MemRegistre m_Memory; |
salco | 11:496453b45e25 | 49 | |
salco | 8:e017e3d527d7 | 50 | /** |
salco | 8:e017e3d527d7 | 51 | * @brief Constructeur priver appler par la fonction getInstance() |
salco | 8:e017e3d527d7 | 52 | */ |
salco | 8:e017e3d527d7 | 53 | CtrlBridge(); |
salco | 8:e017e3d527d7 | 54 | ~CtrlBridge(); |
salco | 11:496453b45e25 | 55 | |
salco | 8:e017e3d527d7 | 56 | private: |
salco | 11:496453b45e25 | 57 | Serial ssc32; |
salco | 11:496453b45e25 | 58 | ComSpi spiLowSpeed, spiHighSpeed; |
salco | 9:7295385f02b2 | 59 | |
salco | 8:e017e3d527d7 | 60 | public: |
salco | 11:496453b45e25 | 61 | Serial pc; |
salco | 28:ac5c6350ed9a | 62 | inline string getFlagUpdate(const unsigned char &adresse) { |
salco | 28:ac5c6350ed9a | 63 | string flag,data; |
salco | 28:ac5c6350ed9a | 64 | flag.clear(); |
salco | 28:ac5c6350ed9a | 65 | data.clear(); |
salco | 28:ac5c6350ed9a | 66 | flag.append(1,7); |
salco | 28:ac5c6350ed9a | 67 | send(adresse,flag,data); |
salco | 28:ac5c6350ed9a | 68 | return flag; |
salco | 28:ac5c6350ed9a | 69 | } |
salco | 28:ac5c6350ed9a | 70 | inline string getDataUpdate(const unsigned char &adresse) { |
salco | 28:ac5c6350ed9a | 71 | string flag,data; |
salco | 28:ac5c6350ed9a | 72 | flag.clear(); |
salco | 28:ac5c6350ed9a | 73 | data.clear(); |
salco | 28:ac5c6350ed9a | 74 | flag.append(1,7); |
salco | 28:ac5c6350ed9a | 75 | send(adresse,flag,data); |
salco | 28:ac5c6350ed9a | 76 | return data; |
salco | 28:ac5c6350ed9a | 77 | } |
salco | 15:91b3c572d9df | 78 | bool send( const unsigned char &adresse, string &flag, string &data); |
salco | 11:496453b45e25 | 79 | |
salco | 14:ca1a9230ba7f | 80 | /*string findModule(const typeModue &t); |
salco | 14:ca1a9230ba7f | 81 | string findModule(const sousType_Actionneur &st); |
salco | 14:ca1a9230ba7f | 82 | string findModule(const sousType_Memoire &st); |
salco | 14:ca1a9230ba7f | 83 | string findModule(const sousType_Capteur &st); |
salco | 14:ca1a9230ba7f | 84 | string findModule(const positionSpatial &p); |
salco | 28:ac5c6350ed9a | 85 | |
salco | 14:ca1a9230ba7f | 86 | string findModule(const typeModue &t, const sousType_Actionneur &st); |
salco | 14:ca1a9230ba7f | 87 | string findModule(const typeModue &t, const sousType_Memoire &st); |
salco | 14:ca1a9230ba7f | 88 | string findModule(const typeModue &t, const sousType_Capteur &st); |
salco | 14:ca1a9230ba7f | 89 | string findModule(const typeModue &t, const positionSpatial &p);*/ //complex pour le moment on le fera en temps voulue |
salco | 28:ac5c6350ed9a | 90 | |
salco | 14:ca1a9230ba7f | 91 | string findModule(const char &peripheriqueID, const char &type, const char &sousType, const char &posSpatial); |
salco | 28:ac5c6350ed9a | 92 | |
salco | 14:ca1a9230ba7f | 93 | int size(const char &peripheriqueID, const char &type, const char &sousType, const char &posSpatial); |
salco | 8:e017e3d527d7 | 94 | /** |
salco | 8:e017e3d527d7 | 95 | * @brief Methode permetant une seul instance de la classe |
salco | 8:e017e3d527d7 | 96 | * @return Retourne l'unique instance de la classe |
salco | 8:e017e3d527d7 | 97 | */ |
salco | 8:e017e3d527d7 | 98 | static CtrlBridge *getInstance(); |
salco | 11:496453b45e25 | 99 | |
salco | 14:ca1a9230ba7f | 100 | bool initCom(void); |
salco | 14:ca1a9230ba7f | 101 | |
salco | 14:ca1a9230ba7f | 102 | bool isValide(char portID) { |
salco | 14:ca1a9230ba7f | 103 | return (m_regPortUse & (1<<portID))?true:false; |
salco | 14:ca1a9230ba7f | 104 | }; |
salco | 11:496453b45e25 | 105 | bool tryComPort(char portID);//just faire le sync et crc pour voire si lautre est la |
salco | 11:496453b45e25 | 106 | |
salco | 28:ac5c6350ed9a | 107 | void clearALL (void) { |
salco | 28:ac5c6350ed9a | 108 | m_Memory.remAllActioneur(); |
salco | 28:ac5c6350ed9a | 109 | m_Memory.remAllCapteur(); |
salco | 28:ac5c6350ed9a | 110 | m_Memory.remAllMemoire(); |
salco | 28:ac5c6350ed9a | 111 | }; |
salco | 28:ac5c6350ed9a | 112 | |
salco | 14:ca1a9230ba7f | 113 | //fonction quelquonque pour communiquer avec les module |
salco | 14:ca1a9230ba7f | 114 | //fonction quelquonque pour faire des recherche dans les module dispo |
salco | 14:ca1a9230ba7f | 115 | //autre fonction pour jouer avec MemRegistre |
salco | 11:496453b45e25 | 116 | |
salco | 2:4c5b0f6d0a6b | 117 | }; |
salco | 2:4c5b0f6d0a6b | 118 | #endif // CTRLBRIDGE_H |