
//[2012.07.23.월][수정!!!]{---------------------------------------------------
//사용자용은 존재하지만 [기계닉스:전용] 은 존재하지 않았다.
//금일, [G.M.RC.BASiC-IDE] 를 [맷돌C] 로 만들때 필요하여 [기계닉스:전용] 을 새로 만든다.
//}--------------------------------------------------------------------------

#include  "gmrcbasic-msg.h"

struct GMRCCONFIG
{
  //[!]{----------------------------------------------------------------------------
  //<G.M.RC.BASiC> 안의 EEprom 에 설정되는 항목을 그대로 정리.
  //
  //설정을 완전하게 1:1 로 대응하게 하기 위하여 MCU 의 설정과 완전히 동일하게 선언.
  //
  //<*.gmrcconfig> 문서를 [저장/열기] 하는 경우 이 구조체를 사용.
  //
  //IDE 와는 무관하고 오직 [제어기 내부 설정] 용으로만 사용된다.
  //즉, 현재 IDE 상태를 반영하지만 <*.gmrcconfig> 문서를 IDE 에 반영하지는 않는다.
  //이는 모든 내용을 다 1:1 로 표시할수 없기 때문.
  //
  //[주의!!!]************************************************************************
  //이 [구조체] 는 <*.gmrcconfig> 용으로만 필요하고 직접 [G.M.RC.BASiC] 을 제어하는 데는 불필요.
  //}-------------------------------------------------------------------------------

  //[영점]
  //{
      //각 서보의 [영점] 조정값.
      unsigned short  영점0도[8];
      unsigned short  영점180도[8];

  //}

  //[A/D 설정]
  //{
      //1 : A
      //0 : D
      unsigned char  AD;

  //}

  //[PWM ON/OFF 설정]
  //{
      //1 : ON
      //0 : OFF
      unsigned char  PWM;

  //}

  //[주기]
  //{
      unsigned char  주기;

  //}

  //[문자열]
  //{
      //문자열은 최대 <450 바이트> 까지 사용가능하므로 넉넉하게 설정.
      char           문자열[512];

  //}

  //[시작 각도/속도]
  //{
      unsigned short  시작각도듀티[8];

      unsigned char   시작속도[8];

  //}

};


//**************************************************************************
//[통신 함수]*****************************************************************
//**************************************************************************

void UART_Txd(unsigned char p출력값);

void UART_TxdX(unsigned char  *p자료열,
               int             p크기);

//[2023.10.15.일][완료]
unsigned char UART_Rxd(unsigned char  *r읽은바이트,
                       //[2023.10.15.일][추가]
                       unsigned int    p제한시간ms);

unsigned char UART_RxdX(unsigned char  *r자료열,
                        int             p크기);

//**************************************************************************
//[흐름 제어]*****************************************************************
//**************************************************************************

//[2023.10.15.일][완료]
unsigned char _GMRCBASIC_Ack(void);

//[2023.10.15.일][완료]
unsigned char _GMRCBASIC_WaitReport(//[2023.10.15.일][추가]
                                    unsigned int  p제한시간ms);

//**************************************************************************
//[공통 사용]*****************************************************************
//**************************************************************************

unsigned char _GMRCBASIC_MemSet(unsigned char  p제어기번호);

//d_MSG_DegSet
unsigned char _GMRCBASIC_Degree(unsigned char  p제어기번호,
                                unsigned char  p서보번호,
                                unsigned char  p속도종류,
                                unsigned char  p각도);

unsigned char _GMRCBASIC_DegMem(unsigned char  p제어기번호,
                                unsigned char  p서보번호,
                                unsigned char  p속도종류,
                                unsigned char  p각도);

unsigned char _GMRCBASIC_DegMemX(unsigned char   p제어기번호,
                                 unsigned char   p설정개수,
                                 unsigned char   p속도종류,
                                 unsigned char  *p각도);

unsigned char _GMRCBASIC_DegRead(unsigned char   p제어기번호,
                                 unsigned char   p서보번호,
                                 unsigned char  *r각도);

unsigned char _GMRCBASIC_DegMemXT(unsigned char   p제어기번호,
                                  unsigned char   p설정개수,
                                  unsigned char   p속도종류,
                                  unsigned char   p속도,
                                  unsigned char  *p각도);

//d_MSG_SpdSet
unsigned char _GMRCBASIC_Speed(unsigned char  p제어기번호,
                               unsigned char  p서보번호,
                               unsigned char  p속도);

unsigned char _GMRCBASIC_SpdMem(unsigned char  p제어기번호,
                                unsigned char  p서보번호,
                                unsigned char  p속도);

unsigned char _GMRCBASIC_SpdMemX(unsigned char   p제어기번호,
                                 unsigned char   p설정개수,
                                 unsigned char  *p속도);

unsigned char _GMRCBASIC_SpdRead(unsigned char   p제어기번호,
                                 unsigned char   p서보번호,
                                 unsigned char  *r속도);

unsigned char _GMRCBASIC_StartSpd8Set(unsigned char   p제어기번호,
                                      unsigned char  *p속도);

unsigned char _GMRCBASIC_StartSpd8Read(unsigned char   p제어기번호,
                                       unsigned char  *r속도);

//d_MSG_DegSpdSet
unsigned char _GMRCBASIC_DegSpd(unsigned char  p제어기번호,
                                unsigned char  p서보번호,
                                unsigned char  p속도종류,
                                unsigned char  p각도,
                                unsigned char  p속도);

unsigned char _GMRCBASIC_DegSpdMem(unsigned char  p제어기번호,
                                   unsigned char  p서보번호,
                                   unsigned char  p속도종류,
                                   unsigned char  p각도,
                                   unsigned char  p속도);

//d_MSG_TickSet
unsigned char _GMRCBASIC_Pulse(unsigned char   p제어기번호,
                               unsigned char   p서보번호,
                               unsigned char   p속도종류,
                               unsigned short  p듀티);

unsigned char _GMRCBASIC_Pos0TickSet(unsigned char   p제어기번호,
                                     unsigned char   p서보번호,
                                     unsigned short  p듀티);

unsigned char _GMRCBASIC_Pos0TickRead(unsigned char    p제어기번호,
                                      unsigned char    p서보번호,
                                      unsigned short  *r듀티);

unsigned char _GMRCBASIC_Pos180TickSet(unsigned char   p제어기번호,
                                       unsigned char   p서보번호,
                                       unsigned short  p듀티);

unsigned char _GMRCBASIC_Pos180TickRead(unsigned char    p제어기번호,
                                        unsigned char    p서보번호,
                                        unsigned short  *r듀티);

unsigned char _GMRCBASIC_StartDegTick8Set(unsigned char    p제어기번호,
                                          unsigned short  *p각도듀티);

unsigned char _GMRCBASIC_StartDegTick8Read(unsigned char    p제어기번호,
                                           unsigned short  *r각도듀티);

unsigned char _GMRCBASIC_Report(unsigned char  p제어기번호);

//d_MSG_ReportTimeSet
unsigned char _GMRCBASIC_ReportTime(unsigned char   p제어기번호,
                                    unsigned char   p서보번호,
                                    unsigned char   p완료보고비율);

//d_MSG_ReportTimeSetX
unsigned char _GMRCBASIC_ReportTimeX(unsigned char   p제어기번호,
                                     unsigned char   p설정개수,
                                     unsigned char  *p완료보고비율);

//d_MSG_AccelDivSet
unsigned char _GMRCBASIC_AccelDiv(unsigned char   p제어기번호,
                                  unsigned char   p서보번호,
                                  unsigned char   p가감속상수);

//d_MSG_AccelDivSetX
unsigned char _GMRCBASIC_AccelDivX(unsigned char   p제어기번호,
                                   unsigned char   p설정개수,
                                   unsigned char  *p가감속상수);

unsigned char _GMRCBASIC_AdSet(unsigned char  p제어기번호,
                               unsigned char  p아날로그_디지탈);

unsigned char _GMRCBASIC_AdRead(unsigned char   p제어기번호,
                                unsigned char  *r아날로그_디지탈);

unsigned char _GMRCBASIC_PwmSet(unsigned char  p제어기번호,
                                unsigned char  pPwm);

unsigned char _GMRCBASIC_PwmRead(unsigned char   p제어기번호,
                                 unsigned char  *rPwm);

unsigned char _GMRCBASIC_PwmStart(unsigned char  p제어기번호);

unsigned char _GMRCBASIC_PwmStop(unsigned char  p제어기번호);

unsigned char _GMRCBASIC_PeriodSet(unsigned char  p제어기번호,
                                   unsigned char  p주기);

unsigned char _GMRCBASIC_PeriodRead(unsigned char   p제어기번호,
                                    unsigned char  *r주기);

unsigned char _GMRCBASIC_StringSet(unsigned char   p제어기번호,
                                   char           *p문자열);

unsigned char _GMRCBASIC_StringRead(unsigned char   p제어기번호,
                                    //전달받은 문자열 반환.
                                    char           *r문자열);

unsigned char _GMRCBASIC_Save(unsigned char  p제어기번호);

unsigned char _GMRCBASIC_CtrlReset(unsigned char  p제어기번호);

unsigned char _GMRCBASIC_EEpromInit(unsigned char  p제어기번호);












