|
| 1 | +/* |
| 2 | + This project 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 | + Deviation 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 Deviation. If not, see <http://www.gnu.org/licenses/>. |
| 14 | + */ |
| 15 | + |
| 16 | +#include "common.h" |
| 17 | +#include "protocol/interface.h" |
| 18 | +#include "config/model.h" |
| 19 | +#include "config/tx.h" |
| 20 | + |
| 21 | +#include <stdlib.h> |
| 22 | + |
| 23 | +#define GPIOA 0xAAAAAAAA |
| 24 | +#define GPIOB 0xBBBBBBBB |
| 25 | +#define GPIOC 0xCCCCCCCC |
| 26 | +#define GPIOD 0xDDDDDDDD |
| 27 | +#define GPIOE 0xEEEEEEEE |
| 28 | +#define GPIOF 0xFFFFFFFF |
| 29 | +#define GPIOG 0xABCDEFAB |
| 30 | +void SPI_ProtoInit() {} |
| 31 | +void MCU_InitModules() { |
| 32 | + Transmitter.module_enable[CYRF6936].port = GPIOB; |
| 33 | + Transmitter.module_enable[CYRF6936].pin = 1 << 12; |
| 34 | + Transmitter.module_poweramp = 1; |
| 35 | +}; |
| 36 | +int MCU_SetPin(struct mcu_pin *port, const char *name) { |
| 37 | + switch(name[0]) { |
| 38 | + case 'A': |
| 39 | + case 'a': |
| 40 | + port->port = GPIOA; break; |
| 41 | + case 'B': |
| 42 | + case 'b': |
| 43 | + port->port = GPIOB; break; |
| 44 | + case 'C': |
| 45 | + case 'c': |
| 46 | + port->port = GPIOC; break; |
| 47 | + case 'D': |
| 48 | + case 'd': |
| 49 | + port->port = GPIOD; break; |
| 50 | + case 'E': |
| 51 | + case 'e': |
| 52 | + port->port = GPIOE; break; |
| 53 | + case 'F': |
| 54 | + case 'f': |
| 55 | + port->port = GPIOF; break; |
| 56 | + case 'G': |
| 57 | + case 'g': |
| 58 | + port->port = GPIOG; break; |
| 59 | + case 'S': |
| 60 | + case 's': |
| 61 | + port->port = SWITCH_ADDRESS; break; |
| 62 | + default: |
| 63 | + if(strcasecmp(name, "None") == 0) { |
| 64 | + port->port = 0; |
| 65 | + port->pin = 0; |
| 66 | + return 1; |
| 67 | + } |
| 68 | + return 0; |
| 69 | + } |
| 70 | + if (port->port != SWITCH_ADDRESS) { |
| 71 | + int x = atoi(name+1); |
| 72 | + if (x > 15) |
| 73 | + return 0; |
| 74 | + port->pin = 1 << x; |
| 75 | + } else { |
| 76 | + port->pin = strtol(name+1,NULL, 16); |
| 77 | + } |
| 78 | + if(port == &Transmitter.module_enable[0]) { |
| 79 | + printf("Set CYRF6936 Enable: %s ", name); |
| 80 | + } else if(port == &Transmitter.module_enable[1]) { |
| 81 | + printf("Set A7105 Enable: %s ", name); |
| 82 | + } else if(port == &Transmitter.module_enable[2]) { |
| 83 | + printf("Set CC2500 Enable: %s ", name); |
| 84 | + } else if(port == &Transmitter.module_enable[3]) { |
| 85 | + printf("Set NRF24L01 Enable: %s ", name); |
| 86 | + } else { |
| 87 | + return 0; |
| 88 | + } |
| 89 | + printf("port: %08x pin: %04x\n", port->port, port->pin); |
| 90 | + return 1; |
| 91 | +} |
| 92 | + |
| 93 | +const char *MCU_GetPinName(char *str, struct mcu_pin *port) |
| 94 | +{ |
| 95 | + switch(port->port) { |
| 96 | + case GPIOA: str[0] = 'A'; break; |
| 97 | + case GPIOB: str[0] = 'B'; break; |
| 98 | + case GPIOC: str[0] = 'C'; break; |
| 99 | + case GPIOD: str[0] = 'D'; break; |
| 100 | + case GPIOE: str[0] = 'E'; break; |
| 101 | + case GPIOF: str[0] = 'F'; break; |
| 102 | + case GPIOG: str[0] = 'G'; break; |
| 103 | + default: return "None"; break; |
| 104 | + } |
| 105 | + for(int i = 0; i < 16; i++) { |
| 106 | + if(port->pin == (1uL << i)) { |
| 107 | + sprintf(str+1, "%d", i); |
| 108 | + return str; |
| 109 | + } |
| 110 | + } |
| 111 | + return "None"; |
| 112 | +} |
| 113 | + |
| 114 | +int SPI_ConfigSwitch(unsigned csn_high, unsigned csn_low) { |
| 115 | + (void)csn_high; |
| 116 | + (void)csn_low; |
| 117 | + return 1; |
| 118 | +} |
| 119 | + |
| 120 | +int SPI_ProtoGetPinConfig(int module, int state) { |
| 121 | + (void)module; |
| 122 | + (void)state; |
| 123 | + return 0; |
| 124 | +} |
| 125 | + |
| 126 | +u8 PROTOSPI_read3wire() { return 0x00; } |
| 127 | + |
| 128 | +u8 PROTOSPI_xfer(u8 byte) { return byte; } |
| 129 | + |
| 130 | +#ifdef PROTO_HAS_A7105 |
| 131 | +int A7105_Reset() { return 1; } |
| 132 | +#endif |
| 133 | + |
| 134 | +#ifdef PROTO_HAS_CC2500 |
| 135 | +int CC2500_Reset() { return 1;} |
| 136 | +#endif //PROTO_HAS_CC2500 |
| 137 | +/* CYRF */ |
| 138 | +int CYRF_Reset() {return 1;} |
| 139 | + |
| 140 | +void SPI_AVRProgramInit() {} |
| 141 | +void PWM_Initialize() {} |
| 142 | +void PWM_Stop() {} |
| 143 | +void PPM_Enable(unsigned low_time, volatile u16 *pulses) { |
| 144 | + int i; |
| 145 | + printf("PPM: low=%d ", (int)low_time); |
| 146 | + for(i = 0; pulses[i]; i++) |
| 147 | + printf("%04d ", pulses[i]); |
| 148 | + printf("\n"); |
| 149 | +} |
0 commit comments