Port of flash_cc2531 to FreeBSD. This is likely more just include a wiringPi compatible library for FreeBSD. Any new files are BSD licensed and NOT GPLv3 license.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

81 lines
2.2 KiB

  1. /***********************************************************************
  2. Copyright © 2019 Jean Michault.
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  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. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <https://www.gnu.org/licenses/>.
  13. *************************************************************************/
  14. #include <wiringPi.h>
  15. #include <stdlib.h>
  16. #include <stdio.h>
  17. #include <stdbool.h>
  18. #include <string.h>
  19. #include <stdint.h>
  20. #include <unistd.h>
  21. #include "CCDebugger.h"
  22. void helpo()
  23. {
  24. fprintf(stderr,"usage : cc_erase [-d pin_DD] [-c pin_DC] [-r pin_reset]\n");
  25. fprintf(stderr," -c : change pin_DC (default 27)\n");
  26. fprintf(stderr," -d : change pin_DD (default 28)\n");
  27. fprintf(stderr," -r : change reset pin (default 24)\n");
  28. fprintf(stderr," -m : change multiplier for time delay (default auto)\n");
  29. }
  30. int main(int argc,char *argv[])
  31. {
  32. int opt;
  33. int rePin=-1;
  34. int dcPin=-1;
  35. int ddPin=-1;
  36. int setMult=-1;
  37. while( (opt=getopt(argc,argv,"m:d:c:r:h?")) != -1)
  38. {
  39. switch(opt)
  40. {
  41. case 'm' :
  42. setMult=atoi(optarg);
  43. break;
  44. case 'd' : // DD pinglo
  45. ddPin=atoi(optarg);
  46. break;
  47. case 'c' : // DC pinglo
  48. dcPin=atoi(optarg);
  49. break;
  50. case 'r' : // restarigi pinglo
  51. rePin=atoi(optarg);
  52. break;
  53. case 'h' : // helpo
  54. case '?' : // helpo
  55. helpo();
  56. exit(0);
  57. break;
  58. }
  59. }
  60. // initialize GPIO and debugger
  61. cc_init(rePin,dcPin,ddPin);
  62. if(setMult>0) cc_setmult(setMult);
  63. // enter debug mode
  64. cc_enter();
  65. // get ChipID :
  66. uint16_t res;
  67. res = cc_getChipID();
  68. printf(" ID = %04x.\n",res);
  69. // erase flash
  70. res = cc_chipErase();
  71. printf(" erase result = %04x.\n",res);
  72. cc_setActive(false);
  73. }