Browse Source

dip 수정 중

feat/dipSwitch
gudae 3 weeks ago
parent
commit
2a05c8fa23
  1. BIN
      DefaultBuild/delay.obj
  2. BIN
      DefaultBuild/i2c.obj
  3. BIN
      DefaultBuild/multical.abs
  4. 4
      DefaultBuild/multical.clnk
  5. 325
      DefaultBuild/multical.map
  6. 148
      DefaultBuild/multical.mot
  7. BIN
      DefaultBuild/owi.obj
  8. BIN
      DefaultBuild/r_cg_cgc.obj
  9. BIN
      DefaultBuild/r_cg_cgc_user.obj
  10. BIN
      DefaultBuild/r_cg_serial.obj
  11. BIN
      DefaultBuild/r_cg_serial_user.obj
  12. BIN
      DefaultBuild/r_cg_wdt.obj
  13. BIN
      DefaultBuild/r_cg_wdt_user.obj
  14. BIN
      DefaultBuild/r_main.obj
  15. BIN
      DefaultBuild/r_systeminit.obj
  16. BIN
      DefaultBuild/uart.obj
  17. 2223
      multical.mtpj
  18. 1866
      multical.rcpe
  19. 423
      multical.temp.mtud
  20. 177
      r_cg_serial.c
  21. 15
      r_cg_serial.h
  22. 161
      r_cg_serial_user.c
  23. 357
      r_main.c
  24. 1
      r_systeminit.c

BIN
DefaultBuild/delay.obj

Binary file not shown.

BIN
DefaultBuild/i2c.obj

Binary file not shown.

BIN
DefaultBuild/multical.abs

Binary file not shown.

4
DefaultBuild/multical.clnk

@ -8,6 +8,10 @@
-Input=DefaultBuild\r_cg_serial_user.obj -Input=DefaultBuild\r_cg_serial_user.obj
-Input=DefaultBuild\r_cg_wdt.obj -Input=DefaultBuild\r_cg_wdt.obj
-Input=DefaultBuild\r_cg_wdt_user.obj -Input=DefaultBuild\r_cg_wdt_user.obj
-Input=DefaultBuild\owi.obj
-Input=DefaultBuild\i2c.obj
-Input=DefaultBuild\uart.obj
-Input=DefaultBuild\delay.obj
-SECURITY_ID=00000000000000000000 -SECURITY_ID=00000000000000000000
-DEVICE=C:\Program Files (x86)\Renesas Electronics\CS+\CC\Device\RL78\Devicefile\DR5F10PPJ.DVF -DEVICE=C:\Program Files (x86)\Renesas Electronics\CS+\CC\Device\RL78\Devicefile\DR5F10PPJ.DVF
-DEBug -DEBug

325
DefaultBuild/multical.map

@ -1,4 +1,4 @@
Renesas Optimizing Linker (W3.07.00 ) 12-Jan-2026 09:55:02 Renesas Optimizing Linker (W3.07.00 ) 12-Jan-2026 13:17:55
*** Options *** *** Options ***
@ -13,6 +13,10 @@ Renesas Optimizing Linker (W3.07.00 ) 12-Jan-2026 09:55:02
-Input=DefaultBuild\r_cg_serial_user.obj -Input=DefaultBuild\r_cg_serial_user.obj
-Input=DefaultBuild\r_cg_wdt.obj -Input=DefaultBuild\r_cg_wdt.obj
-Input=DefaultBuild\r_cg_wdt_user.obj -Input=DefaultBuild\r_cg_wdt_user.obj
-Input=DefaultBuild\owi.obj
-Input=DefaultBuild\i2c.obj
-Input=DefaultBuild\uart.obj
-Input=DefaultBuild\delay.obj
-SECURITY_ID=00000000000000000000 -SECURITY_ID=00000000000000000000
-DEVICE=C:\Program Files (x86)\Renesas Electronics\CS+\CC\Device\RL78\Devicefile\DR5F10PPJ.DVF -DEVICE=C:\Program Files (x86)\Renesas Electronics\CS+\CC\Device\RL78\Devicefile\DR5F10PPJ.DVF
-DEBug -DEBug
@ -34,309 +38,16 @@ Renesas Optimizing Linker (W3.07.00 ) 12-Jan-2026 09:55:02
*** Error information *** *** Error information ***
*** Mapping List *** E0562310:Undefined external symbol "_R_ADC_Create" referenced in "DefaultBuild\r_main.obj"
E0562310:Undefined external symbol "_R_ADC_Get_Result" referenced in "DefaultBuild\uart.obj"
SECTION START END SIZE ALIGN E0562310:Undefined external symbol "_R_ADC_Stop" referenced in "DefaultBuild\uart.obj"
.vect E0562310:Undefined external symbol "_R_IICA0_Create" referenced in "DefaultBuild\r_main.obj"
00000000 0000007f 80 0 E0562310:Undefined external symbol "_R_IICA0_Create" referenced in "DefaultBuild\i2c.obj"
.constf E0562310:Undefined external symbol "_R_IICA0_Master_Receive" referenced in "DefaultBuild\i2c.obj"
00000080 00000080 0 2 E0562310:Undefined external symbol "_uart_rx_buffer" referenced in "DefaultBuild\r_main.obj"
.init_array E0562310:Undefined external symbol "_R_ADC_Start" referenced in "DefaultBuild\uart.obj"
00000080 00000080 0 2 E0562310:Undefined external symbol "_uart_rx_length" referenced in "DefaultBuild\r_main.obj"
.data E0562310:Undefined external symbol "_R_ADC_Set_OperationOn" referenced in "DefaultBuild\r_main.obj"
00000080 00000080 0 2 E0562310:Undefined external symbol "_uart_rx_index" referenced in "DefaultBuild\r_main.obj"
.sdata E0562310:Undefined external symbol "_uart_rx_done" referenced in "DefaultBuild\r_main.obj"
00000080 00000080 0 2 E0562310:Undefined external symbol "_R_IICA0_Master_Send" referenced in "DefaultBuild\i2c.obj"
.option_byte
000000c0 000000c3 4 1
.security_id
000000c4 000000cd a 1
.RLIB
000000c4 000000c4 0 1
.SLIB
000000c4 000000c4 0 1
.text
000000ce 00000280 1b3 1
.textf
00000281 000006db 45b 1
.const
00003000 00003000 0 2
.bss
000faf00 000faf1f 20 2
.dataR
000faf20 000faf20 0 2
.sbss
000ffe20 000ffe20 0 2
.sdataR
000ffe20 000ffe20 0 2
*** Total Section Size ***
RAMDATA SECTION: 00000020 Byte(s)
ROMDATA SECTION: 0000008e Byte(s)
PROGRAM SECTION: 0000060e Byte(s)
*** Symbol List ***
SECTION=
FILE= START END SIZE
SYMBOL ADDR SIZE INFO COUNTS OPT
SECTION=.vect
FILE=rlink_generates_03
00000000 0000007f 80
SECTION=.option_byte
FILE=rlink_generates_01
000000c0 000000c3 4
SECTION=.security_id
FILE=rlink_generates_02
000000c4 000000cd a
SECTION=.text
FILE=DefaultBuild\cstart.obj
000000ce 00000140 73
_start
000000ce 0 none ,g *
_exit
0000013e 0 none ,g *
_atexit
00000140 0 none ,g *
FILE=DefaultBuild\r_cg_serial_user.obj
00000141 0000027e 13e
_r_uart0_interrupt_receive@1
00000141 5f func ,l *
_r_uart0_interrupt_send@1
000001a0 2f func ,l *
_r_uart1_interrupt_receive@1
000001cf 5f func ,l *
_r_uart1_interrupt_send@1
0000022e 2f func ,l *
_r_iica0_interrupt@1
0000025d 22 func ,l *
FILE=DefaultBuild\r_cg_wdt_user.obj
0000027f 00000280 2
_r_wdt_interrupt@1
0000027f 2 func ,l *
SECTION=.textf
FILE=DefaultBuild\stkinit.obj
00000281 000002c4 44
_stkinit
00000281 0 none ,g *
LSTINIT1
0000028f 0 none ,l *
LSTINIT2
000002b9 0 none ,l *
LSTINIT3
000002c4 0 none ,l *
FILE=DefaultBuild\r_main.obj
000002c5 000002cd 9
_main
000002c5 5 func ,g *
_R_MAIN_UserInit
000002ca 4 func ,g *
FILE=DefaultBuild\r_systeminit.obj
000002ce 0000030e 41
_R_Systeminit
000002ce 3a func ,g *
_hdwinit
00000308 7 func ,g *
FILE=DefaultBuild\r_cg_cgc.obj
0000030f 00000338 2a
_R_CGC_Create
0000030f 2a func ,g *
FILE=DefaultBuild\r_cg_cgc_user.obj
00000339 0000033b 3
_R_CGC_Get_ResetSource
00000339 3 func ,g *
FILE=DefaultBuild\r_cg_serial.obj
0000033c 00000623 2e8
_R_SAU0_Create
0000033c 12 func ,g *
_R_UART0_Create
0000034e 6e func ,g *
_R_UART0_Start
000003bc 26 func ,g *
_R_UART0_Stop
000003e2 1e func ,g *
_R_UART0_Receive
00000400 18 func ,g *
_R_UART0_Send
00000418 26 func ,g *
_R_SAU1_Create
0000043e 12 func ,g *
_R_UART1_Create
00000450 6e func ,g *
_R_UART1_Start
000004be 26 func ,g *
_R_UART1_Stop
000004e4 1e func ,g *
_R_UART1_Receive
00000502 18 func ,g *
_R_UART1_Send
0000051a 26 func ,g *
_R_IICA0_Create
00000540 50 func ,g *
_R_IICA0_Stop
00000590 5 func ,g *
_R_IICA0_StopCondition
00000595 5 func ,g *
_R_IICA0_Master_Send
0000059a 43 func ,g *
_R_IICA0_Master_Receive
000005dd 47 func ,g *
FILE=DefaultBuild\r_cg_serial_user.obj
00000624 000006c7 a4
_r_uart0_callback_receiveend@1
00000624 1 func ,l *
_r_uart0_callback_softwareoverrun@1
00000625 1 func ,l *
_r_uart0_callback_sendend@1
00000626 1 func ,l *
_r_uart0_callback_error@1
00000627 1 func ,l *
_r_uart1_callback_receiveend@1
00000628 1 func ,l *
_r_uart1_callback_softwareoverrun@1
00000629 1 func ,l *
_r_uart1_callback_sendend@1
0000062a 1 func ,l *
_r_uart1_callback_error@1
0000062b 1 func ,l *
_iica0_masterhandler@1
0000062c 91 func ,l *
_r_iica0_callback_master_error@1
000006bd 1 func ,l *
_r_iica0_callback_master_receiveend@1
000006be 5 func ,l *
_r_iica0_callback_master_sendend@1
000006c3 5 func ,l *
FILE=DefaultBuild\r_cg_wdt.obj
000006c8 000006db 14
_R_WDT_Create
000006c8 10 func ,g *
_R_WDT_Restart
000006d8 4 func ,g *
SECTION=.bss
FILE=DefaultBuild\r_cg_serial.obj
000faf00 000faf1f 20
_gp_uart0_tx_address
000faf00 2 data ,g *
_g_uart0_tx_count
000faf02 2 data ,g *
_gp_uart0_rx_address
000faf04 2 data ,g *
_g_uart0_rx_count
000faf06 2 data ,g *
_g_uart0_rx_length
000faf08 2 data ,g *
_gp_uart1_tx_address
000faf0a 2 data ,g *
_g_uart1_tx_count
000faf0c 2 data ,g *
_gp_uart1_rx_address
000faf0e 2 data ,g *
_g_uart1_rx_count
000faf10 2 data ,g *
_g_uart1_rx_length
000faf12 2 data ,g *
_g_iica0_master_status_flag
000faf14 1 data ,g *
_g_iica0_slave_status_flag
000faf15 1 data ,g *
_gp_iica0_rx_address
000faf16 2 data ,g *
_g_iica0_rx_len
000faf18 2 data ,g *
_g_iica0_rx_cnt
000faf1a 2 data ,g *
_gp_iica0_tx_address
000faf1c 2 data ,g *
_g_iica0_tx_cnt
000faf1e 2 data ,g *
Absolute value symbols
FILE=rlink_generates_04
__s.text
000000ce 0 none ,g *
__e.text
00000281 0 none ,g *
__s.textf
00000281 0 none ,g *
__e.textf
000006dc 0 none ,g *
__s.const
00003000 0 none ,g *
__e.const
00003000 0 none ,g *
__s.constf
00000080 0 none ,g *
__e.constf
00000080 0 none ,g *
__s.data
00000080 0 none ,g *
__e.data
00000080 0 none ,g *
__s.sdata
00000080 0 none ,g *
__e.sdata
00000080 0 none ,g *
__s.bss
000faf00 0 none ,g *
__e.bss
000faf20 0 none ,g *
__s.sbss
000ffe20 0 none ,g *
__e.sbss
000ffe20 0 none ,g *
__s.dataR
000faf20 0 none ,g *
__e.dataR
000faf20 0 none ,g *
__s.sdataR
000ffe20 0 none ,g *
__e.sdataR
000ffe20 0 none ,g *
__s.init_array
00000080 0 none ,g *
__e.init_array
00000080 0 none ,g *
__s.RLIB
000000c4 0 none ,g *
__e.RLIB
000000c4 0 none ,g *
__s.SLIB
000000c4 0 none ,g *
__e.SLIB
000000c4 0 none ,g *
__s.option_byte
000000c0 0 none ,g *
__e.option_byte
000000c4 0 none ,g *
__s.security_id
000000c4 0 none ,g *
__e.security_id
000000ce 0 none ,g *
__s.vect
00000000 0 none ,g *
__e.vect
00000080 0 none ,g *
__RAM_ADDR_START
000faf00 0 none ,g *
__RAM_ADDR_END
000ffee0 0 none ,g *
__STACK_ADDR_START
000ffe20 0 none ,g *
__STACK_ADDR_END
000faf20 0 none ,g *
*** Unfilled Areas ***
AREA START END
*** Delete Symbols ***
SYMBOL SIZE INFO

148
DefaultBuild/multical.mot

@ -1,7 +1,7 @@
S00E00006D756C746963616C6D6F7446 S00E00006D756C746963616C6D6F7446
S1130000CE0000007F02000000000000000000009D S1130000CE0000005D0200000000000000000000BF
S1130010000000000000A0014101000000000000F9 S1130010000000000000A0014101000000000000F9
S113002000000000000000005D020000000000006D S113002000000000000000000000000000000000CC
S113003000000000000000000000000000002E028C S113003000000000000000000000000000002E028C
S1130040CF010000000000000000000000000000DC S1130040CF010000000000000000000000000000DC
S1130050000000000000000000000000000000009C S1130050000000000000000000000000000000009C
@ -9,102 +9,76 @@ S1130060000000000000000000000000000000008C
S1130070000000000000000000000000000000007C S1130070000000000000000000000000000000007C
S10700C0FFFFF8043E S10700C0FFFFF8043E
S10D00C4000000000000000000002E S10D00C4000000000000000000002E
S11300CECBF820FE3020AFFC810200FC0803003682 S11300CECBF820FE3014AFFC5F0200FCE2020036D7
S11300DE00AF3020AFEF04CC0000A747DFF9362085 S11300DE00AF3014AFEF04CC0000A747DFF9362091
S11300EEFE3020FEEF04CC0000A747DFF9410032BA S11300EEFE3020FEEF04CC0000A747DFF9410032BA
S11300FE0000EF08B3114980004820AFF643DFF447 S11300FE0000EF08B3114980004814AFF643DFF453
S113010E4100320000EF08B3114980004820FEF68A S113010E4100320000EF08B3114980004820FEF68A
S113011E43DFF4320000EF0FB3B3410011798000D6 S113011E43DFF4320000EF0FB3B3410011798000D6
S113012ECEFC00C361CAC2F643DFEDFCC50200F685 S113012ECEFC00C361CAC2F643DFEDFCA30200F6A7
S113013EEFFED7C1C3C5C78EFD708EFCC1C7AF021B S113013EEFFED7C1C3C5C78EFD708EFCC1C7AF021B
S113014E01605C0798008800318EBF06018800D1DB S113014E01605C0798008800318EBF06018800D1DB
S113015EDD068800FC2706008D129801AF08AF4219 S113015EDD068800FC1D05008D129801AF08AF4224
S113016E06AF880161D318EB04AF99A204AFA206BF S113016E06AF880161D318EB04AF99A204AFA206BF
S113017EAFAF08AF4206AFDF0CFC240600EF06312A S113017EAFAF08AF4206AFDF0CFC1A0500EF063135
S113018E8EFC250600C0C09EFC609EFDC6C4C2C087 S113018E8EFC1B0500C0C09EFC609EFDC6C4C2C092
S113019E61FCC1C3C5C78EFD708EFCC1AF02AF61D9 S113019E61FCC1C3C5C78EFD708EFCC1AF02AF61D9
S11301AE68DD18EB00AF899D10A200AFB202AFC09C S11301AE68DD18EB00AF899D10A200AFB202AFC09C
S11301BE9EFC609EFDC6C4C2C061FCFC260600EF18 S11301BE9EFC609EFDC6C4C2C061FCFC1C0500EF23
S11301CEEEC1C3C5C78EFD708EFCC1C7AF420160C0 S11301CEEEC1C3C5C78EFD708EFCC1C7AF420160C0
S11301DE5C0798008800318EBF46018800D1DD0689 S11301DE5C0798008800318EBF46018800D1DD0689
S11301EE8800FC2B06008E4A9801AF12AF4210AF66 S11301EE8800FC2105008E4A9801AF12AF4210AF71
S11301FE880161D318EB0EAF99A20EAFA210AFAF68 S11301FE880161D318EB0EAF99A20EAFA210AFAF68
S113020E12AF4210AFDF0CFC280600EF06318EFC55 S113020E12AF4210AFDF0CFC1E0500EF06318EFC60
S113021E290600C0C09EFC609EFDC6C4C2C061FC1F S113021E1F0500C0C09EFC609EFDC6C4C2C061FC2A
S113022EC1C3C5C78EFD708EFCC1AF0CAF6168DD56 S113022EC1C3C5C78EFD708EFCC1AF0CAF6168DD56
S113023E18EB0AAF899E48A20AAFB20CAFC09EFC5F S113023E18EB0AAF899E48A20AAFB20CAFC09EFC5F
S113024E609EFDC6C4C2C061FCFC2A0600EFEEC16E S113024E609EFDC6C4C2C061FCFC200500EFEE61D9
S113025EC3C5C78EFD708EFCC18E51318E319D612A S104025EFC9F
S113026ED8FC2C0600C09EFC609EFDC6C4C2C061B4 S113025F16C80300AEF82761D339315E12F643DDB9
S106027EFC61FC20 S113026F27BBBC02BC04BC06BC08BC0ABC0CBC0E3D
S113028116C80300AEF82761D339315E12F643DD97 S113027FBC10BC12BC14BC16BC18BC1ABC1CBC1ED3
S113029127BBBC02BC04BC06BC08BC0ABC0CBC0E1B S113028F3704200037B3EFD6AEF847DD06F6BBA729
S11302A1BC10BC12BC14BC16BC18BC1ABC1CBC1EB1 S113029FA7EFF5D7FE0200EFFE717AFAD7341600F6
S11302B13704200037B3EFD6AEF847DD06F6BBA707 S11302AFCA0000CA0100CA0200CA0300CA0400CA75
S11302C1A7EFF5D7FE0200EFFE717AFAD7341600D4 S11302BF0500CA0600CA0700CA0800FC130300FCA5
S11302D1CA0000CA0100CA0200CA0300CA0400CA53 S11302CFE90200FC160300FC180400FC220500F5EB
S11302E10500CA0600CA0700CA0800FC390300FC5D S11302DF7800D7717BFAFEC4FFD736C4027182CE81
S11302F10F0300FC3C0300FC3E0400FC400500FC31 S11302EFA000717AA1714BA4CC03017128C50271CE
S1130301C80600F57800D7717BFAFEC0FFD736C462 S11302FF6AA1716BA4710BA1CC04808C046C429C19
S1130311027182CEA000717AA1714BA4CC03017148 S113030F0471A3D78EA8D77120F00000000000302D
S113032128C502716AA1716BA4710BA1CC04808CE4 S113031F4000BF1601FE0100D7347000AAA4086C78
S1130331046C429C0471A3D78EA8D77120F00000ED S113032F0308BAA4711AE5711BE1712AE5712BE177
S1130341000000304400BF1601FE0100D7347000E4 S113033F711AED711AE9712AED712AE9302280BA26
S1130351AAA4086C0308BAA4711AE5711BE1712AF5 S113034F98309780BA9CC91000CE89718A9930076A
S1130361E5712BE1711AED711AE9712AED712AE92E S113035F00BA96302201BA9A309740BA9EC9120059
S1130371302200BA98309780BA9CC91000CE897196 S113036F20AAA8086C0108BAA8AAB0BAB0AAAA0809
S11303818A99300700BA96302201BA9A309740BA56 S113037F6C0108BAAA51406F21FF9E216A012051D6
S11303919EC91200CEAAA8086C0108BAA8AAB0BACC S113038FDF5F21FF9E21D7341201AA06086C0108F2
S11303A1B0AAAA086C0108BAAA51406F21FF9E2184 S113039FBA06AA08086C0108BA08A9086C0308B9B8
S11303B16A012051DF5F21FF9E21D7341201AA0671 S11303AF711BE1712BE1711BE5712BE5D7711AE517
S11303C1086C0108BA06AA08086C0108BA08A90849 S11303BF712AE5341401A9086C0308B9AA06085C6C
S11303D16C0308B9711BE1712BE1711BE5712BE50C S11303CFFE08BA06711BE1712BE1D714136168DDC6
S11303E1D7711AE5712AE5341401A9086C0308B917 S11303DF0EF6BF06AF13BF08AF15BF04AFF6D73085
S11303F1AA06085CFE08BA06711BE1712BE1D71449 S11303EF8100D714136168DD1C15BF00AF13BF0262
S1130401136168DD0EF6BF06AF13BF08AF15BF0455 S11303FFAF711AE5EB00AF899D10A200AFB202AF47
S1130411AFF6D7308100D714136168DD1C15BF0016 S113040F711BE5F6D7308100D77130F00000000082
S1130421AF13BF02AF711AE5EB00AF899D10A200B3 S113041F00304400BF5601FE0100D7347000AAE437
S1130431AFB202AF711BE5F6D7308100D77130F04E S113042F086C0308BAE4715AE7715BE3716AE77108
S11304410000000000304400BF5601FE0100D73413 S113043F6BE3715AEF715AEB716AEF716AEB302209
S11304517000AAE4086C0308BAE4715AE7715BE31B S113044F00BAD8309780BADCCB4800CE8971AA990C
S1130461716AE7716BE3715AEF715AEB716AEF715B S113045F300700BAD6302201BADA309740BADECB71
S11304716AEB302200BAD8309780BADCCB4800CE80 S113046F4A00CEAAE8086C0108BAE8AAF0BAF0AAC2
S11304818971AA99300700BAD6302201BADA3097B5 S113047FEA086C0108BAEA51026F21FF9E216A0152
S113049140BADECB4A00CEAAE8086C0108BAE8AA41 S113048F0451FB5F21FF9E21D7345201AA06086C49
S11304A1F0BAF0AAEA086C0108BAEA51026F21FF16 S113049F0108BA06AA08086C0108BA08A9086C036F
S11304B19E216A010451FB5F21FF9E21D734520121 S11304AF08B9715BE3716BE3715BE7716BE7D7714C
S11304C1AA06086C0108BA06AA08086C0108BA0849 S11304BF5AE7716AE7345401A9086C0308B9AA060C
S11304D1A9086C0308B9715BE3716BE3715BE771A4 S11304CF085CFE08BA06715BE3716BE3D714136122
S11304E16BE7D7715AE7716AE7345401A9086C03C1 S11304DF68DD0EF6BF10AF13BF12AF15BF0EAFF628
S11304F108B9AA06085CFE08BA06715BE3716BE3EE S11304EFD7308100D714136168DD1C15BF0AAF1311
S1130501D714136168DD0EF6BF10AF13BF12AF1518 S11304FFBF0CAF715AE7EB0AAF899E48A20AAFB29D
S1130511BF0EAFF6D7308100D714136168DD1C1507 S113050F0CAF715BE7F6D7308100D7D7D7D7D7D7E2
S1130521BF0AAF13BF0CAF715AE7EB0AAF899E48FC S113051FD7D7D7710AE4710BE0710AEC710AE8714D
S1130531A20AAFB20CAF715BE7F6D7308100D77175 S10A052F0BE4D7CEABACD7FF
S113054140F00036300271F3712AE6712BE2712A10
S1130551EE712AEA5A06F3510C6F26FF9E26713872
S11305613102343002CA024CCA03558A01718A9A93
S113057101CA0410711A52710A5271C371B271A283
S1130581712BE671F271E251F35F26FF9E26D7715A
S1130591783002D771003002D7C79800C3C6712AD8
S11305A1E631E4520C31F25108712BE6308200C27B
S11305B1D771103002712BE66091D070DFFA31945B
S11305C15103F7EF0332830015BF1EAF17BF1CAFF2
S11305D1F514AF8800718B9E5013C2D7C79800C31E
S11305E1C6712AE631E4520C31F25108712BE6301E
S11305F18200C2D771103002712BE66091D070DF96
S1130601FA31945103F7EF0332830015BF18AFF6A3
S1130611BF1AAF17BF16AFF514AF8800718A9E5089
S113062113C2D7D7D7D7D7D7D7D7D731E2520CAF41
S11306311EAF6168DD05E6FE8200D78F14AF318EEF
S1130641319DDC2931A4513451806F14AF9F14AF13
S113065131B4510F71303002AF1EAF6168DF22FE39
S11306616000D736300271A271B371D2D731B4515F
S11306711D31A251E3AF1EAF6168DDDC300200EF32
S1130681B6EB1CAF899E50A21CAFB21EAFD7AF1AF6
S1130691AF4218AFDE22EB16AF8E5099A216AFA26D
S11306A11AAFAF1AAF4218AFDF0936300271A37126
S11306B1B2EFB771503002D7FE0200D7D7710030C4
S11306C102D771003002D7710AE4710BE0710AECB0
S10E06D1710AE8710BE4D7CEABACD784
S9030000FC S9030000FC

BIN
DefaultBuild/owi.obj

Binary file not shown.

BIN
DefaultBuild/r_cg_cgc.obj

Binary file not shown.

BIN
DefaultBuild/r_cg_cgc_user.obj

Binary file not shown.

BIN
DefaultBuild/r_cg_serial.obj

Binary file not shown.

BIN
DefaultBuild/r_cg_serial_user.obj

Binary file not shown.

BIN
DefaultBuild/r_cg_wdt.obj

Binary file not shown.

BIN
DefaultBuild/r_cg_wdt_user.obj

Binary file not shown.

BIN
DefaultBuild/r_main.obj

Binary file not shown.

BIN
DefaultBuild/r_systeminit.obj

Binary file not shown.

BIN
DefaultBuild/uart.obj

Binary file not shown.

2223
multical.mtpj

File diff suppressed because it is too large

1866
multical.rcpe

File diff suppressed because it is too large

423
multical.temp.mtud

File diff suppressed because one or more lines are too long

177
r_cg_serial.c

@ -54,13 +54,6 @@ volatile uint16_t g_uart1_tx_count; /* uart1 transmit data number */
volatile uint8_t * gp_uart1_rx_address; /* uart1 receive buffer address */ volatile uint8_t * gp_uart1_rx_address; /* uart1 receive buffer address */
volatile uint16_t g_uart1_rx_count; /* uart1 receive data number */ volatile uint16_t g_uart1_rx_count; /* uart1 receive data number */
volatile uint16_t g_uart1_rx_length; /* uart1 receive data length */ volatile uint16_t g_uart1_rx_length; /* uart1 receive data length */
volatile uint8_t g_iica0_master_status_flag; /* iica0 master flag */
volatile uint8_t g_iica0_slave_status_flag; /* iica0 slave flag */
volatile uint8_t * gp_iica0_rx_address; /* iica0 receive buffer address */
volatile uint16_t g_iica0_rx_len; /* iica0 receive data length */
volatile uint16_t g_iica0_rx_cnt; /* iica0 receive data count */
volatile uint8_t * gp_iica0_tx_address; /* iica0 send buffer address */
volatile uint16_t g_iica0_tx_cnt; /* iica0 send data count */
/* Start user code for global. Do not edit comment generated here */ /* Start user code for global. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */ /* End user code. Do not edit comment generated here */
@ -77,7 +70,7 @@ void R_SAU0_Create(void)
NOP(); NOP();
NOP(); NOP();
NOP(); NOP();
SPS0 = _0004_SAU_CK00_FCLK_4 | _0040_SAU_CK01_FCLK_4; SPS0 = _0000_SAU_CK00_FCLK_0 | _0040_SAU_CK01_FCLK_4;
R_UART0_Create(); R_UART0_Create();
} }
@ -100,7 +93,7 @@ void R_UART0_Create(void)
/* Set INTSR0 low priority */ /* Set INTSR0 low priority */
SRPR10 = 1U; SRPR10 = 1U;
SRPR00 = 1U; SRPR00 = 1U;
SMR00 = _0020_SAU_SMRMN_INITIALVALUE | _0000_SAU_CLOCK_SELECT_CK00 | _0000_SAU_TRIGGER_SOFTWARE | SMR00 = _0020_SAU_SMRMN_INITIALVALUE | _8000_SAU_CLOCK_SELECT_CK01 | _0000_SAU_TRIGGER_SOFTWARE |
_0002_SAU_MODE_UART | _0000_SAU_TRANSFER_END; _0002_SAU_MODE_UART | _0000_SAU_TRANSFER_END;
SCR00 = _8000_SAU_TRANSMISSION | _0000_SAU_PARITY_NONE | _0080_SAU_LSB | _0010_SAU_STOP_1 | _0007_SAU_LENGTH_8; SCR00 = _8000_SAU_TRANSMISSION | _0000_SAU_PARITY_NONE | _0080_SAU_LSB | _0010_SAU_STOP_1 | _0007_SAU_LENGTH_8;
SDR00 = _CE00_UART0_TRANSMIT_DIVISOR; SDR00 = _CE00_UART0_TRANSMIT_DIVISOR;
@ -109,7 +102,7 @@ void R_UART0_Create(void)
SMR01 = _0020_SAU_SMRMN_INITIALVALUE | _0000_SAU_CLOCK_SELECT_CK00 | _0100_SAU_TRIGGER_RXD | _0000_SAU_EDGE_FALL | SMR01 = _0020_SAU_SMRMN_INITIALVALUE | _0000_SAU_CLOCK_SELECT_CK00 | _0100_SAU_TRIGGER_RXD | _0000_SAU_EDGE_FALL |
_0002_SAU_MODE_UART | _0000_SAU_TRANSFER_END; _0002_SAU_MODE_UART | _0000_SAU_TRANSFER_END;
SCR01 = _4000_SAU_RECEPTION | _0000_SAU_PARITY_NONE | _0080_SAU_LSB | _0010_SAU_STOP_1 | _0007_SAU_LENGTH_8; SCR01 = _4000_SAU_RECEPTION | _0000_SAU_PARITY_NONE | _0080_SAU_LSB | _0010_SAU_STOP_1 | _0007_SAU_LENGTH_8;
SDR01 = _CE00_UART0_RECEIVE_DIVISOR; SDR01 = _2000_UART0_RECEIVE_DIVISOR;
SO0 |= _0001_SAU_CH0_DATA_OUTPUT_1; SO0 |= _0001_SAU_CH0_DATA_OUTPUT_1;
SOL0 |= _0000_SAU_CHANNEL0_NORMAL; /* output level normal */ SOL0 |= _0000_SAU_CHANNEL0_NORMAL; /* output level normal */
SOE0 |= _0001_SAU_CH0_OUTPUT_ENABLE; /* enable UART0 output */ SOE0 |= _0001_SAU_CH0_OUTPUT_ENABLE; /* enable UART0 output */
@ -362,169 +355,5 @@ MD_STATUS R_UART1_Send(uint8_t * const tx_buf, uint16_t tx_num)
return (status); return (status);
} }
/***********************************************************************************************************************
* Function Name: R_IICA0_Create
* Description : This function initializes the IICA0 module.
* Arguments : None
* Return Value : None
***********************************************************************************************************************/
void R_IICA0_Create(void)
{
IICA0EN = 1U; /* supply IICA0 clock */
IICE0 = 0U; /* disable IICA0 operation */
IICAMK0 = 1U; /* disable INTIICA0 interrupt */
IICAIF0 = 0U; /* clear INTIICA0 interrupt flag */
/* Set INTIICA0 low priority */
IICAPR10 = 1U;
IICAPR00 = 1U;
/* Set SCLA0, SDAA0 pin */
P6 &= 0xF3U;
PM6 |= 0x0CU;
SMC0 = 0U;
IICWL0 = _4C_IICA0_IICWL_VALUE;
IICWH0 = _55_IICA0_IICWH_VALUE;
IICCTL01 |= _01_IICA_fCLK_HALF;
SVA0 = _10_IICA0_MASTERADDRESS;
STCEN0 = 1U;
IICRSV0 = 1U;
SPIE0 = 0U;
WTIM0 = 1U;
ACKE0 = 1U;
IICAMK0 = 0U;
IICE0 = 1U;
LREL0 = 1U;
/* Set SCLA0, SDAA0 pin */
PM6 &= 0xF3U;
}
/***********************************************************************************************************************
* Function Name: R_IICA0_Stop
* Description : This function stops IICA0 module operation.
* Arguments : None
* Return Value : None
***********************************************************************************************************************/
void R_IICA0_Stop(void)
{
IICE0 = 0U; /* disable IICA0 operation */
}
/***********************************************************************************************************************
* Function Name: R_IICA0_StopCondition
* Description : This function sets IICA0 stop condition flag.
* Arguments : None
* Return Value : None
***********************************************************************************************************************/
void R_IICA0_StopCondition(void)
{
SPT0 = 1U; /* set stop condition flag */
}
/***********************************************************************************************************************
* Function Name: R_IICA0_Master_Send
* Description : This function starts to send data as master mode.
* Arguments : adr -
* send address
* tx_buf -
* transfer buffer pointer
* tx_num -
* buffer size
* wait -
* wait for start condition
* Return Value : status -
* MD_OK or MD_ERROR1 or MD_ERROR2
***********************************************************************************************************************/
MD_STATUS R_IICA0_Master_Send(uint8_t adr, uint8_t * const tx_buf, uint16_t tx_num, uint8_t wait)
{
MD_STATUS status = MD_OK;
IICAMK0 = 1U; /* disable INTIICA0 interrupt */
if ((1U == IICBSY0) && (0U == MSTS0))
{
/* Check bus busy */
IICAMK0 = 0U; /* enable INTIICA0 interrupt */
status = MD_ERROR1;
}
else
{
STT0 = 1U; /* send IICA0 start condition */
IICAMK0 = 0U; /* enable INTIICA0 interrupt */
/* Wait */
while (wait--)
{
;
}
if (0U == STD0)
{
status = MD_ERROR2;
}
/* Set parameter */
g_iica0_tx_cnt = tx_num;
gp_iica0_tx_address = tx_buf;
g_iica0_master_status_flag = _00_IICA_MASTER_FLAG_CLEAR;
adr &= (uint8_t)~0x01U; /* set send mode */
IICA0 = adr; /* send address */
}
return (status);
}
/***********************************************************************************************************************
* Function Name: R_IICA0_Master_Receive
* Description : This function starts to receive IICA0 data as master mode.
* Arguments : adr -
* receive address
* rx_buf -
* receive buffer pointer
* rx_num -
* buffer size
* wait -
* wait for start condition
* Return Value : status -
* MD_OK or MD_ERROR1 or MD_ERROR2
***********************************************************************************************************************/
MD_STATUS R_IICA0_Master_Receive(uint8_t adr, uint8_t * const rx_buf, uint16_t rx_num, uint8_t wait)
{
MD_STATUS status = MD_OK;
IICAMK0 = 1U; /* disable INTIIA0 interrupt */
if ((1U == IICBSY0) && (0U == MSTS0))
{
/* Check bus busy */
IICAMK0 = 0U; /* enable INTIIA0 interrupt */
status = MD_ERROR1;
}
else
{
STT0 = 1U; /* set IICA0 start condition */
IICAMK0 = 0U; /* enable INTIIA0 interrupt */
/* Wait */
while (wait--)
{
;
}
if (0U == STD0)
{
status = MD_ERROR2;
}
/* Set parameter */
g_iica0_rx_len = rx_num;
g_iica0_rx_cnt = 0U;
gp_iica0_rx_address = rx_buf;
g_iica0_master_status_flag = _00_IICA_MASTER_FLAG_CLEAR;
adr |= 0x01U; /* set receive mode */
IICA0 = adr; /* receive address */
}
return (status);
}
/* Start user code for adding. Do not edit comment generated here */ /* Start user code for adding. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */ /* End user code. Do not edit comment generated here */

15
r_cg_serial.h

@ -348,13 +348,10 @@ Macro definitions (Register bit)
/*********************************************************************************************************************** /***********************************************************************************************************************
Macro definitions Macro definitions
***********************************************************************************************************************/ ***********************************************************************************************************************/
#define _CE00_UART0_RECEIVE_DIVISOR (0xCE00U) #define _2000_UART0_RECEIVE_DIVISOR (0x2000U)
#define _CE00_UART0_TRANSMIT_DIVISOR (0xCE00U) #define _CE00_UART0_TRANSMIT_DIVISOR (0xCE00U)
#define _CE00_UART1_RECEIVE_DIVISOR (0xCE00U) #define _CE00_UART1_RECEIVE_DIVISOR (0xCE00U)
#define _CE00_UART1_TRANSMIT_DIVISOR (0xCE00U) #define _CE00_UART1_TRANSMIT_DIVISOR (0xCE00U)
#define _10_IICA0_MASTERADDRESS (0x10U)
#define _55_IICA0_IICWH_VALUE (0x55U)
#define _4C_IICA0_IICWL_VALUE (0x4CU)
/*********************************************************************************************************************** /***********************************************************************************************************************
Typedef definitions Typedef definitions
@ -383,16 +380,6 @@ static void r_uart1_callback_error(uint8_t err_type);
static void r_uart1_callback_receiveend(void); static void r_uart1_callback_receiveend(void);
static void r_uart1_callback_sendend(void); static void r_uart1_callback_sendend(void);
static void r_uart1_callback_softwareoverrun(uint16_t rx_data); static void r_uart1_callback_softwareoverrun(uint16_t rx_data);
void R_IICA0_Create(void);
MD_STATUS R_IICA0_Master_Send(uint8_t adr, uint8_t * const tx_buf, uint16_t tx_num, uint8_t wait);
MD_STATUS R_IICA0_Master_Receive(uint8_t adr, uint8_t * const rx_buf, uint16_t rx_num, uint8_t wait);
void R_IICA0_Stop(void);
void R_IICA0_StopCondition(void);
static void r_iica0_callback_master_sendend(void);
static void r_iica0_callback_master_receiveend(void);
static void r_iica0_callback_master_error(MD_STATUS flag);
static void iica0_masterhandler(void);
static void iica0_slavehandler(void);
/* Start user code for function. Do not edit comment generated here */ /* Start user code for function. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */ /* End user code. Do not edit comment generated here */

161
r_cg_serial_user.c

@ -42,7 +42,6 @@ Pragma directive
#pragma interrupt r_uart0_interrupt_receive(vect=INTSR0) #pragma interrupt r_uart0_interrupt_receive(vect=INTSR0)
#pragma interrupt r_uart1_interrupt_send(vect=INTST1) #pragma interrupt r_uart1_interrupt_send(vect=INTST1)
#pragma interrupt r_uart1_interrupt_receive(vect=INTSR1) #pragma interrupt r_uart1_interrupt_receive(vect=INTSR1)
#pragma interrupt r_iica0_interrupt(vect=INTIICA0)
/* Start user code for pragma. Do not edit comment generated here */ /* Start user code for pragma. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */ /* End user code. Do not edit comment generated here */
@ -59,13 +58,6 @@ extern volatile uint16_t g_uart1_tx_count; /* uart1 send data number
extern volatile uint8_t * gp_uart1_rx_address; /* uart1 receive buffer address */ extern volatile uint8_t * gp_uart1_rx_address; /* uart1 receive buffer address */
extern volatile uint16_t g_uart1_rx_count; /* uart1 receive data number */ extern volatile uint16_t g_uart1_rx_count; /* uart1 receive data number */
extern volatile uint16_t g_uart1_rx_length; /* uart1 receive data length */ extern volatile uint16_t g_uart1_rx_length; /* uart1 receive data length */
extern volatile uint8_t g_iica0_master_status_flag; /* iica0 master flag */
extern volatile uint8_t g_iica0_slave_status_flag; /* iica0 slave flag */
extern volatile uint8_t * gp_iica0_rx_address; /* iica0 receive buffer address */
extern volatile uint16_t g_iica0_rx_cnt; /* iica0 receive data length */
extern volatile uint16_t g_iica0_rx_len; /* iica0 receive data count */
extern volatile uint8_t * gp_iica0_tx_address; /* iica0 send buffer address */
extern volatile uint16_t g_iica0_tx_cnt; /* iica0 send data count */
/* Start user code for global. Do not edit comment generated here */ /* Start user code for global. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */ /* End user code. Do not edit comment generated here */
@ -285,158 +277,5 @@ static void r_uart1_callback_error(uint8_t err_type)
/* End user code. Do not edit comment generated here */ /* End user code. Do not edit comment generated here */
} }
/***********************************************************************************************************************
* Function Name: r_iica0_interrupt
* Description : This function is INTIICA0 interrupt service routine.
* Arguments : None
* Return Value : None
***********************************************************************************************************************/
static void __near r_iica0_interrupt(void)
{
if ((IICS0 & _80_IICA_STATUS_MASTER) == 0x80U)
{
iica0_masterhandler();
}
}
/***********************************************************************************************************************
* Function Name: iica0_masterhandler
* Description : This function is IICA0 master handler.
* Arguments : None
* Return Value : None
***********************************************************************************************************************/
static void iica0_masterhandler(void)
{
/* Detection of stop condition handling */
if ((0U == IICBSY0) && (g_iica0_tx_cnt != 0U))
{
r_iica0_callback_master_error(MD_SPT);
}
else
{
/* Control for sended address */
if ((g_iica0_master_status_flag & _80_IICA_ADDRESS_COMPLETE) == 0U)
{
if (1U == ACKD0)
{
g_iica0_master_status_flag |= _80_IICA_ADDRESS_COMPLETE;
if (1U == TRC0)
{
WTIM0 = 1U;
if (g_iica0_tx_cnt > 0U)
{
IICA0 = *gp_iica0_tx_address;
gp_iica0_tx_address++;
g_iica0_tx_cnt--;
}
else
{
r_iica0_callback_master_sendend();
}
}
else
{
ACKE0 = 1U;
WTIM0 = 0U;
WREL0 = 1U;
}
}
else
{
r_iica0_callback_master_error(MD_NACK);
}
}
else
{
/* Master send control */
if (1U == TRC0)
{
if ((0U == ACKD0) && (g_iica0_tx_cnt != 0U))
{
r_iica0_callback_master_error(MD_NACK);
}
else
{
if (g_iica0_tx_cnt > 0U)
{
IICA0 = *gp_iica0_tx_address;
gp_iica0_tx_address++;
g_iica0_tx_cnt--;
}
else
{
r_iica0_callback_master_sendend();
}
}
}
/* Master receive control */
else
{
if (g_iica0_rx_cnt < g_iica0_rx_len)
{
*gp_iica0_rx_address = IICA0;
gp_iica0_rx_address++;
g_iica0_rx_cnt++;
if (g_iica0_rx_cnt == g_iica0_rx_len)
{
ACKE0 = 0U;
WTIM0 = 1U;
WREL0 = 1U;
}
else
{
WREL0 = 1U;
}
}
else
{
r_iica0_callback_master_receiveend();
}
}
}
}
}
/***********************************************************************************************************************
* Function Name: r_iica0_callback_master_error
* Description : This function is a callback function when IICA0 master error occurs.
* Arguments : None
* Return Value : None
***********************************************************************************************************************/
static void r_iica0_callback_master_error(MD_STATUS flag)
{
/* Start user code. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */
}
/***********************************************************************************************************************
* Function Name: r_iica0_callback_master_receiveend
* Description : This function is a callback function when IICA0 finishes master reception.
* Arguments : None
* Return Value : None
***********************************************************************************************************************/
static void r_iica0_callback_master_receiveend(void)
{
SPT0 = 1U;
/* Start user code. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */
}
/***********************************************************************************************************************
* Function Name: r_iica0_callback_master_sendend
* Description : This function is a callback function when IICA0 finishes master transmission.
* Arguments : None
* Return Value : None
***********************************************************************************************************************/
static void r_iica0_callback_master_sendend(void)
{
SPT0 = 1U;
/* Start user code. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */
}
/* Start user code for adding. Do not edit comment generated here */ /* Start user code for adding. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */ /* End user code. Do not edit comment generated here */

357
r_main.c

@ -34,6 +34,34 @@ Includes
#include "r_cg_serial.h" #include "r_cg_serial.h"
#include "r_cg_wdt.h" #include "r_cg_wdt.h"
/* Start user code for include. Do not edit comment generated here */ /* Start user code for include. Do not edit comment generated here */
#include "common.h"
#include "r_cg_macrodriver.h"
#include <string.h>
#include <ctype.h>
#include <stddef.h>
#include <r_cg_port.h>
#define UART_RX_BUF_SIZE 96
#define CMD_MAX 529
// pin10~13 ↔ P1.0~P1.3 가정
#define X0C_PORT P1
#define X0C_PORTMODE PM1
#define X0C_CH0_MASK _01_Pn0_OUTPUT_1 // P1.0 = 1
#define X0C_CH1_MASK _02_Pn1_OUTPUT_1 // P1.1 = 1
#define X0C_CH2_MASK _04_Pn2_OUTPUT_1 // P1.2 = 1
#define X0C_CH3_MASK _08_Pn3_OUTPUT_1 // P1.3 = 1
#define X0C_MASK (X0C_CH0_MASK|X0C_CH1_MASK|X0C_CH2_MASK|X0C_CH3_MASK)
extern volatile uint8_t uart_rx_done;
extern volatile uint8_t uart_rx_index;
extern volatile uint8_t uart_rx_buffer[UART_RX_BUF_SIZE];
extern volatile uint16_t uart_rx_length;
static uint8_t uart0_rx_buffer[11];
const unsigned char *d;
unsigned int len;
/* End user code. Do not edit comment generated here */ /* End user code. Do not edit comment generated here */
#include "r_cg_userdefine.h" #include "r_cg_userdefine.h"
@ -41,12 +69,332 @@ Includes
Pragma directive Pragma directive
***********************************************************************************************************************/ ***********************************************************************************************************************/
/* Start user code for pragma. Do not edit comment generated here */ /* Start user code for pragma. Do not edit comment generated here */
static unsigned char hex2byte(char h, char l)
{
unsigned char hi, lo;
if (h >= 'a' && h <= 'f') h -= 32;
if (l >= 'a' && l <= 'f') l -= 32;
hi = (h >= 'A') ? h - 'A' + 10 : h - '0';
lo = (l >= 'A') ? l - 'A' + 10 : l - '0';
return (hi << 4) | lo;
}
// === X0C GPIO: P1.0~P1.3 을 pin10~13으로 사용한다고 가정 ===
static void x0c_init(void){
// 출력으로 설정
X0C_PORTMODE &= (uint8_t)~(uint8_t)X0C_MASK;
// 모두 LOW
X0C_PORT &= (uint8_t)~(uint8_t)X0C_MASK;
}
static void x0c_all_low(void){
X0C_PORT &= (uint8_t)~(uint8_t)X0C_MASK;
}
static void x0c_select(uint8_t ch){
// break-before-make
X0C_PORT &= (uint8_t)~(uint8_t)X0C_MASK;
__nop(); __nop(); __nop(); __nop();
switch(ch){
case 0: X0C_PORT = (uint8_t)((X0C_PORT & (uint8_t)~(uint8_t)X0C_MASK) | X0C_CH0_MASK); break;
case 1: X0C_PORT = (uint8_t)((X0C_PORT & (uint8_t)~(uint8_t)X0C_MASK) | X0C_CH1_MASK); break;
case 2: X0C_PORT = (uint8_t)((X0C_PORT & (uint8_t)~(uint8_t)X0C_MASK) | X0C_CH2_MASK); break;
case 3: X0C_PORT = (uint8_t)((X0C_PORT & (uint8_t)~(uint8_t)X0C_MASK) | X0C_CH3_MASK); break;
default: /* 255=all low 등 */ break;
}
}
typedef void (*CmdHandler)(const unsigned char *data, unsigned int len);
void cmd_unknown(const unsigned char *d, unsigned int len)
{
uart_send_string("Unknownaaaaa cmd\r\n");
delay(100000);
}
typedef enum {
PROTOCOL_I2CT,
PROTOCOL_OWIT,
PROTOCOL_I2CW,
PROTOCOL_I2CR,
PROTOCOL_OWIW,
PROTOCOL_OWIR,
PROTOCOL_I2CA,
PROTOCOL_OWIA,
PROTOCOL_OWID,
PROTOCOL_OWIC,
PROTOCOL_I2CC,
PROTOCOL_UNKNOWN
} ProtocolType;
ProtocolType detect_protocol(char header1,char header2)
{
if (header1 == 'I' && header2 == 'W' ) return PROTOCOL_I2CW;
if (header1 == 'I' && header2 == 'R') return PROTOCOL_I2CR;
if (header1 == 'O' && header2 == 'W' ) return PROTOCOL_OWIW;
if (header1 == 'O' && header2 == 'R' ) return PROTOCOL_OWIR;
return PROTOCOL_UNKNOWN;
}
typedef struct {
unsigned char code;
CmdHandler fn;
} CmdMap;
void process_cmd(ProtocolType protocol, uint8_t id/*unsigned char code*/,
const unsigned char *data, unsigned int len)
{
const CmdMap *map = NULL;
int map_size = 0;
int i;
switch (protocol) {
case PROTOCOL_I2CT:
I2C_T_Command_Mode_receiveData(data,(uint8_t)len, id);
break;
case PROTOCOL_OWIT:
OWI_T_CommandMode(data,(uint8_t)len, id);
break;
case PROTOCOL_I2CW:
I2C_Command_Mode_receiveData(data,(uint8_t)len,id);
break;
case PROTOCOL_I2CR:
I2C_Command_Mode_Send((uint8_t)len, id);
break;
case PROTOCOL_OWIW:
OWI_CommandMode(data,(uint8_t)len,id);
break;
case PROTOCOL_OWIR:
OWI_ReadBytesAndPrint(len,id);
break;
case PROTOCOL_I2CA:
I2C_A_Command_Mode_receiveData(data,(uint8_t)len,id);
break;
case PROTOCOL_OWIA:
OWI_A_CommandMode(data,(uint8_t)len,id);
break;
case PROTOCOL_OWID:
OWI_disable();
break;
case PROTOCOL_OWIC:
OWI_Diagnostic(id);
break;
case PROTOCOL_I2CC:
I2C_Diagnostic(id);
break;
default:
cmd_unknown(data, len);
return;
}
}
/* End user code. Do not edit comment generated here */ /* End user code. Do not edit comment generated here */
/*********************************************************************************************************************** /***********************************************************************************************************************
Global variables and functions Global variables and functions
***********************************************************************************************************************/ ***********************************************************************************************************************/
/* Start user code for global. Do not edit comment generated here */ /* Start user code for global. Do not edit comment generated here */
void handle_uart_command_line(void)
{
char line[UART_RX_BUF_SIZE];
while (1)
{
if (uart_rx_done)
{
int i;
int idx = 0;
int pos = 2;
int rx_len;
ProtocolType proto;
uint8_t id;
unsigned int byte_len;
uint8_t cmd[CMD_MAX];
unsigned int k = 0;
uart_rx_done = 0;
rx_len = (int)uart_rx_length;
if (rx_len < 0) rx_len = 0;
if (rx_len > (int)UART_RX_BUF_SIZE - 1) rx_len = (int)UART_RX_BUF_SIZE - 1;
uart_rx_buffer[rx_len] = '\0';
// 한 줄 만들기 (CR 무시, LF에서 끊음)
for (i = 0; i < rx_len && i < (int)sizeof(line) - 1; i++) {
char c = (char)uart_rx_buffer[i];
if (c == '\r') continue;
if (c == '\n') break;
line[idx++] = c;
}
line[idx] = '\0';
/* ============================
* X0C_
* : X0C_011:..., X0C_021:..., X0C_031:..., X0C_041:...
* () X0C_000: -> LOW
* ============================ */
if (idx >= 8 &&
(line[0]=='X' || line[0]=='x') &&
(line[1]=='0' || line[1]=='0') &&
(line[2]=='0' || line[1]=='0') &&
(line[3]=='C' || line[2]=='c') &&
line[4]=='_')
{
int ch = -1;
// 엄격한 포맷 검사: 'X0C_' '0' [1~4|0] '1' ':' (또는 000:)
if (line[5]=='0' && line[8]==':') {
if (line[5]=='0' && line[6]=='0' && line[7]=='0') ch = 0;
else if (line[5]=='0' && line[6]=='0' && line[7]=='1') ch = 1;
else if (line[5]=='2' && line[6]=='1') ch = 1;
else if (line[5]=='3' && line[6]=='1') ch = 2; // pin12
else if (line[5]=='4' && line[6]=='1') ch = 3; // pin13
else if (line[5]=='0' && line[6]=='0') ch = 255; // 000: -> 모두 LOW
}
if (ch == -1) {
uart_send_string("Err:X0C_code\r\n");
goto clear;
}
// 모두 LOW
X0C_PORT &= (uint8_t)~(uint8_t)X0C_MASK;
__nop(); __nop(); __nop(); __nop();
// 선택된 채널만 HIGH
if (ch != 255) {
switch(ch){
case 0: X0C_PORT = (uint8_t)((X0C_PORT & (uint8_t)~(uint8_t)X0C_MASK) | X0C_CH0_MASK); break;
case 1: X0C_PORT = (uint8_t)((X0C_PORT & (uint8_t)~(uint8_t)X0C_MASK) | X0C_CH1_MASK); break;
case 2: X0C_PORT = (uint8_t)((X0C_PORT & (uint8_t)~(uint8_t)X0C_MASK) | X0C_CH2_MASK); break;
case 3: X0C_PORT = (uint8_t)((X0C_PORT & (uint8_t)~(uint8_t)X0C_MASK) | X0C_CH3_MASK); break;
}
delay_us(7000);
}
// 콜론 뒤 명령만 남기도록 버퍼를 앞으로 당김
{
int start = 8; // "X0C_0x1:" 이후 시작 인덱스
int rem = idx - start; // 남은 길이
if (rem <= 0) {
// X0C_만 있는 경우: 단순 ACK 후 종료
uart_send_string("<ACK>X0C\r\n");
goto clear;
}
for (i = 0; i < rem; i++) line[i] = line[start + i];
line[rem] = '\0';
idx = rem;
pos = 2; // 프로토콜 재해석 위해 초기화 (OW/IR/IW/OR의 2글자 이후 위치)
}
}
// (X0C 처리 후) 최소 길이 재검사
if (idx < 7) { uart_send_string("Err:short\r\n"); goto clear; }
{
char h0 = (char)toupper((unsigned char)line[0]);
char h1 = (char)toupper((unsigned char)line[1]);
proto = detect_protocol(h0, h1);
}
if (proto == PROTOCOL_UNKNOWN) { uart_send_string("Err:ID\r\n"); goto clear; }
if (line[pos] == 't' || line[pos] == 'T') {
if (proto == PROTOCOL_OWIW) proto = PROTOCOL_OWIT;
else if (proto == PROTOCOL_I2CW) proto = PROTOCOL_I2CT;
pos++; // 't'
}
if (line[pos] == 'a' || line[pos] == 'A') {
if (proto == PROTOCOL_OWIW) proto = PROTOCOL_OWIA;
else if (proto == PROTOCOL_I2CW) proto = PROTOCOL_I2CA;
pos++; // 'a'
}
if (line[pos] == 'd' || line[pos] == 'D') {
if (proto == PROTOCOL_OWIW) proto = PROTOCOL_OWID;
pos++;
}
if (line[pos] == 'c' || line[pos] == 'C') {
if (proto == PROTOCOL_OWIW) proto = PROTOCOL_OWIC;
else if (proto == PROTOCOL_I2CW) proto = PROTOCOL_I2CC;
pos++;
}
if (line[pos] == '_' || line[pos] == ':') pos++;
if (pos + 1 >= idx) { uart_send_string("Err:id_short\r\n"); goto clear; }
id = hex2byte(line[pos], line[pos+1]);
pos += 2;
if (pos + 2 >= idx ||
!(line[pos] >= '0' && line[pos] <= '9') ||
!(line[pos+1] >= '0' && line[pos+1] <= '9') ||
!(line[pos+2] >= '0' && line[pos+2] <= '9')) {
uart_send_string("Err:len_dec\r\n"); goto clear;
}
byte_len = (unsigned int)(100*(line[pos]-'0') + 10*(line[pos+1]-'0') + (line[pos+2]-'0'));
pos += 3;
if (byte_len > CMD_MAX) { uart_send_string("Err:len_range\r\n"); goto clear; }
if (proto == PROTOCOL_I2CA || proto == PROTOCOL_OWIA) {
if (byte_len != 0 && byte_len != 3) {
uart_send_string("Err:len_a_mode\r\n"); goto clear;
}
if (byte_len == 0) {
if (pos != idx) { uart_send_string("Err:read_no_payload\r\n"); goto clear; }
} else {
if ((int)(pos + (int)byte_len*2) > idx) { uart_send_string("Err:len_mismatch\r\n"); goto clear; }
for (k = 0; k < byte_len; k++) {
cmd[k] = hex2byte(line[pos + 2*k], line[pos + 2*k + 1]);
}
pos += byte_len*2;
if (pos != idx) { uart_send_string("Err:len_trail\r\n"); goto clear; }
}
}
else if (proto == PROTOCOL_OWIT || proto == PROTOCOL_I2CT ||
proto == PROTOCOL_OWIW || proto == PROTOCOL_I2CW)
{
if (byte_len == 0) { uart_send_string("Err:payload0\r\n"); goto clear; }
if ((int)(pos + (int)byte_len*2) > idx) { uart_send_string("Err:len_mismatch\r\n"); goto clear; }
for (k = 0; k < byte_len; k++) {
cmd[k] = hex2byte(line[pos + 2*k], line[pos + 2*k + 1]);
}
pos += byte_len*2;
if (pos != idx) { uart_send_string("Err:len_trail\r\n"); goto clear; }
}
else if (proto == PROTOCOL_OWIR || proto == PROTOCOL_I2CR)
{
if (byte_len == 0) { uart_send_string("Err:read_len_nonzero\r\n"); goto clear; }
if (pos != idx) { uart_send_string("Err:read_no_payload\r\n"); goto clear; }
}
process_cmd(proto, id, cmd, byte_len);
clear:
idx = 0;
uart_rx_index = 0;
uart_rx_length = 0;
R_UART0_Receive((uint8_t *)&uart_rx_buffer[uart_rx_index], 1);
}
}
}
/* End user code. Do not edit comment generated here */ /* End user code. Do not edit comment generated here */
void R_MAIN_UserInit(void); void R_MAIN_UserInit(void);
@ -60,6 +408,12 @@ void main(void)
{ {
R_MAIN_UserInit(); R_MAIN_UserInit();
/* Start user code. Do not edit comment generated here */ /* Start user code. Do not edit comment generated here */
R_UART0_Create();
R_IICA0_Create();
R_UART0_Start();
R_UART0_Receive(&uart_rx_buffer[uart_rx_index], 1);
handle_uart_command_line();
delay(100000);
while (1U) while (1U)
{ {
; ;
@ -77,6 +431,9 @@ void R_MAIN_UserInit(void)
{ {
/* Start user code. Do not edit comment generated here */ /* Start user code. Do not edit comment generated here */
EI(); EI();
R_ADC_Create();
R_ADC_Set_OperationOn();
x0c_init();
/* End user code. Do not edit comment generated here */ /* End user code. Do not edit comment generated here */
} }

1
r_systeminit.c

@ -71,7 +71,6 @@ void R_Systeminit(void)
R_CGC_Create(); R_CGC_Create();
R_SAU0_Create(); R_SAU0_Create();
R_SAU1_Create(); R_SAU1_Create();
R_IICA0_Create();
R_WDT_Create(); R_WDT_Create();
/* Set invalid memory access detection control */ /* Set invalid memory access detection control */

Loading…
Cancel
Save