Line data Source code
1 : /* 2 : This program is free software: you can redistribute it and/or modify 3 : it under the terms of the GNU General Public License as published by 4 : the Free Software Foundation, either version 3 of the License, or 5 : (at your option) any later version. 6 : 7 : This program is distributed in the hope that it will be useful, 8 : but WITHOUT ANY WARRANTY; without even the implied warranty of 9 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 : GNU General Public License for more details. 11 : 12 : You should have received a copy of the GNU General Public License 13 : along with this program. If not, see <http://www.gnu.org/licenses/>. 14 : */ 15 : 16 : #include <AP_HAL/AP_HAL.h> 17 : #include "AP_Compass_ExternalAHRS.h" 18 : 19 : #if AP_COMPASS_EXTERNALAHRS_ENABLED 20 : 21 62 : AP_Compass_Backend *AP_Compass_ExternalAHRS::probe(uint8_t port) 22 : { 23 62 : auto devid = AP_HAL::Device::make_bus_id(AP_HAL::Device::BUS_TYPE_SERIAL,port,0,0); 24 62 : auto *ret = NEW_NOTHROW AP_Compass_ExternalAHRS(); 25 62 : if (ret == nullptr) { 26 0 : return nullptr; 27 : } 28 62 : if (!ret->register_compass(devid)) { 29 62 : delete ret; 30 62 : return nullptr; 31 : } 32 0 : ret->set_external(true); 33 0 : return ret; 34 : } 35 : 36 0 : void AP_Compass_ExternalAHRS::handle_external(const AP_ExternalAHRS::mag_data_message_t &pkt) 37 : { 38 0 : Vector3f field = pkt.field; 39 0 : accumulate_sample(field); 40 0 : } 41 : 42 : #endif // AP_COMPASS_EXTERNALAHRS_ENABLED