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.
SD20.cpp
00001 /* ##################################################################### 00002 SD20.cpp 00003 -------- 00004 00005 Surface Ship, Group 5 00006 --------------------- 00007 00008 Written by: Steven Kay 00009 00010 Date: February 2016 00011 00012 Function: This 00013 00014 Version: 1.0 00015 00016 Version History 00017 --------------- 00018 00019 1.1 rgdfgdfgdfggdfgdg 00020 00021 1.0 gdgddfdddgd 00022 00023 ##################################################################### */ 00024 00025 #include "mbed.h" 00026 #include "SD20.h" 00027 00028 SD20::SD20(I2C *bus) 00029 { 00030 _bus = bus; 00031 _bus -> frequency(BUS_FREQ); 00032 } 00033 00034 int SD20::UpdateChannel(char channelReg, char channelSpeed) 00035 { 00036 // Output new duty cycle to SD20, return 0 if successful, 1 if unsuccessful 00037 updateDutyCycle[0] = channelReg; 00038 updateDutyCycle[1] = channelSpeed; 00039 00040 if(_bus -> write(SD20_ADDRESS,updateDutyCycle,2)) 00041 { 00042 // printf("I2C Failed to write\r\n"); 00043 return 1; 00044 } 00045 else 00046 { 00047 // updateDutyCycle = *(updateDutyCycle+1) 00048 printf("Reg: 0x%02x Data: 0x%02x\r\n",*updateDutyCycle,*(updateDutyCycle+1)); 00049 return 0; 00050 } 00051 } 00052 00053 int SD20::StartStopChannel(uint8_t ServoChannel,bool Start) 00054 { 00055 // Startup a new channel, return 0 if successful, 1 if unsuccessful 00056 if(Start == CHANNEL_START) 00057 { 00058 char startDutyCycle[] = {ServoChannel,CHANNEL_START}; 00059 if(_bus -> write(SD20_ADDRESS,startDutyCycle,OUT_BUF_LEN)) 00060 { 00061 // printf("I2C Failed to write\r\n"); 00062 return 1; 00063 } 00064 else 00065 { 00066 // printf("Reg: 0x%02x Data: 0x%02x\r\n",*newDutyCycle,*(newDutyCycle+1)); 00067 return 0; 00068 } 00069 } 00070 00071 // Stop channel, return 0 if successful, 1 if unsuccessful 00072 else 00073 { 00074 char stopDutyCycle[] = {ServoChannel,CHANNEL_STOP}; 00075 if(_bus -> write(SD20_ADDRESS,stopDutyCycle,OUT_BUF_LEN)) 00076 { 00077 // printf("I2C Failed to write\r\n"); 00078 return 1; 00079 } 00080 else 00081 { 00082 // printf("Reg: 0x%02x Data: 0x%02x\r\n",*newDutyCycle,*(newDutyCycle+1)); 00083 return 0; 00084 } 00085 } 00086 } 00087 00088 int SD20::SetStandardMode() 00089 { 00090 char outputBuf[] = {STD_ETD_MODE_CTRL,STD_MODE}; 00091 if(_bus -> write(SD20_ADDRESS,outputBuf,OUT_BUF_LEN)) 00092 { 00093 // printf("I2C Failed to write\r\n"); 00094 return 1; 00095 } 00096 else 00097 { 00098 // printf("0x%02x sent to Reg: 0x%02x\r\n",*(outputBuf+1),*outputBuf); 00099 return 0; 00100 } 00101 } 00102
Generated on Thu Jul 14 2022 10:56:41 by
1.7.2