Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
pah_comm.c
00001 #include "pah_comm.h" 00002 00003 #include "pah_util.h" 00004 00005 00006 /*============================================================================ 00007 STATIC VARIABLE DEFINITIONS 00008 ============================================================================*/ 00009 static bool _has_drv_comm = false; 00010 static pah_drv_comm_s _drv_comm; 00011 00012 00013 /*============================================================================ 00014 PUBLIC FUNCTION DEFINITIONS 00015 ============================================================================*/ 00016 void pah_comm_set_drv_comm(const pah_drv_comm_s *drv_comm) 00017 { 00018 memcpy(&_drv_comm, drv_comm, sizeof(*drv_comm)); 00019 _has_drv_comm = true; 00020 } 00021 00022 bool pah_comm_write(uint8_t addr, uint8_t data) 00023 { 00024 if (!_has_drv_comm) 00025 return false; 00026 00027 if (_drv_comm.type == pah_drv_comm_spi) 00028 PAH_CLEAR_BIT(addr, 7); //write, bit7 = 0 00029 00030 return PAH_SUCCEEDED(_drv_comm.write(&_drv_comm, addr, data)); 00031 } 00032 00033 bool pah_comm_read(uint8_t addr, uint8_t *data) 00034 { 00035 if (!_has_drv_comm) 00036 return false; 00037 00038 if (_drv_comm.type == pah_drv_comm_spi) 00039 PAH_SET_BIT(addr, 7); //read, bit7 = 1 00040 00041 return PAH_SUCCEEDED(_drv_comm.read(&_drv_comm, addr, data)); 00042 } 00043 00044 bool pah_comm_burst_read(uint8_t addr, uint8_t *data, uint16_t num) 00045 { 00046 if (!_has_drv_comm) 00047 return false; 00048 00049 if (_drv_comm.type == pah_drv_comm_spi) 00050 PAH_SET_BIT(addr, 7); //read, bit7 = 1 00051 00052 return PAH_SUCCEEDED(_drv_comm.burst_read(&_drv_comm, addr, data, num)); 00053 } 00054 00055 pah_comm_bus_e pah_comm_get_bus_type(void) 00056 { 00057 if (_drv_comm.type == pah_drv_comm_spi) 00058 return pah_comm_bus_spi; 00059 return pah_comm_bus_i2c; 00060 }
Generated on Mon Jul 18 2022 04:14:28 by
1.7.2