📄 mca25.lst
字号:
725:io/mca25.c **** #endif
726:io/mca25.c ****
727:io/mca25.c **** //revision 017 !
728:io/mca25.c **** if (count < 50){
729:io/mca25.c **** mca25_uart_init_19200();
730:io/mca25.c **** //reset cam again:
731:io/mca25.c **** MCA25_RESET_LO();
732:io/mca25.c **** _delay_ms(50);
733:io/mca25.c **** MCA25_RESET_HI();
734:io/mca25.c **** }
735:io/mca25.c **** */
736:io/mca25.c ****
737:io/mca25.c **** #if MCA25_DEBUG
738:io/mca25.c **** softuart_puts_progmem("CAM : init (takes ~5sec) ");
739:io/mca25.c **** #endif
740:io/mca25.c ****
741:io/mca25.c **** while (state != 100){
742:io/mca25.c **** //read cam data:
743:io/mca25.c **** if (state<10){
744:io/mca25.c **** //read AT command
745:io/mca25.c **** if ( ! mca25_read_at_command(mca25_buffer)){
746:io/mca25.c **** #if MCA25_DEBUG
747:io/mca25.c **** softuart_puts_progmem("TIMEOUT! (AT) ");
748:io/mca25.c **** #endif
749:io/mca25.c **** if (state == 0){
750:io/mca25.c **** //maybe this is a bad/new (?) mca25 which wants to communicate at 19200 baud!
751:io/mca25.c **** //retry!
752:io/mca25.c **** mca25_uart_init_19200();
753:io/mca25.c **** #if MCA25_DEBUG
754:io/mca25.c **** softuart_puts_progmem(" trying 19200 baud ");
755:io/mca25.c **** #endif
756:io/mca25.c **** if ( ! mca25_read_at_command(mca25_buffer)){
757:io/mca25.c **** #if MCA25_DEBUG
758:io/mca25.c **** softuart_puts_progmem("TIMEOUT! (AT) ");
759:io/mca25.c **** softuart_putnewline();
760:io/mca25.c **** #endif
761:io/mca25.c **** return 0;
762:io/mca25.c **** }else{
763:io/mca25.c **** mca25_is_rev017 = 1;
764:io/mca25.c **** }
765:io/mca25.c **** }else{
766:io/mca25.c **** //state != 0 -> always exit
767:io/mca25.c **** #if MCA25_DEBUG
768:io/mca25.c **** softuart_putnewline();
769:io/mca25.c **** #endif
770:io/mca25.c **** return 0; //read failed -> exit!
771:io/mca25.c **** }
772:io/mca25.c **** }
773:io/mca25.c **** }else{
774:io/mca25.c **** //read MUX packet
775:io/mca25.c **** if( ! mca25_read_mux_packet(mca25_buffer,0)){
776:io/mca25.c **** #if MCA25_DEBUG
777:io/mca25.c **** softuart_puts_progmem("TIMEOUT! (MUX)");
778:io/mca25.c **** softuart_putnewline();
779:io/mca25.c **** #endif
780:io/mca25.c **** return 0; //read failed -> exit!;
781:io/mca25.c **** }
782:io/mca25.c **** }
783:io/mca25.c **** #if MCA25_DEBUG
784:io/mca25.c **** /*if (old_state != state){
785:io/mca25.c **** softuart_put_uint8(state);
786:io/mca25.c **** softuart_putc('-');
787:io/mca25.c **** old_state = state;
788:io/mca25.c **** }*/
789:io/mca25.c **** #endif
790:io/mca25.c **** switch (state){
791:io/mca25.c **** case 0:
792:io/mca25.c **** //we have to wait for AT&F:
793:io/mca25.c **** if (string_compare_progmem_plen("AT&F", mca25_buffer) || string_compare_progmem_plen("AT&F", &m
794:io/mca25.c **** mca25_send_ok();
795:io/mca25.c **** state = 1;
796:io/mca25.c **** }
797:io/mca25.c **** break;
798:io/mca25.c ****
799:io/mca25.c **** case 1:
800:io/mca25.c **** //wait for AT+IPR
801:io/mca25.c **** if (string_compare_progmem_plen("AT+IPR=?", mca25_buffer)){
802:io/mca25.c **** mca25_puts_progmem("+IPR: (),(1200,2400,4800,9600,19200,38400,57600,460800)\r\n\r\nOK\r\n");
803:io/mca25.c **** state = 2;
804:io/mca25.c **** }
805:io/mca25.c **** break;
806:io/mca25.c ****
807:io/mca25.c **** case 2:
808:io/mca25.c **** //wait for AT+IPR SET command
809:io/mca25.c **** if (string_compare_progmem_plen("AT+IPR=460800", mca25_buffer)){
810:io/mca25.c **** mca25_puts_progmem("\r\nOK\r\n"); //bubug: here only 1 \r before OK!
811:io/mca25.c **** //set higher baudrate:
812:io/mca25.c **** mca25_uart_init_460800();
813:io/mca25.c **** //wait ...
814:io/mca25.c **** state = 3;
815:io/mca25.c **** }
816:io/mca25.c **** break;
817:io/mca25.c ****
818:io/mca25.c **** case 3:
819:io/mca25.c **** //wait for mux info req
820:io/mca25.c **** if (string_compare_progmem_plen("AT+CMUX=?", mca25_buffer)){
821:io/mca25.c **** mca25_puts_progmem("\r\r\n+CMUX: (0),(0),(1-7),(31),(10),(3),(30),(10),(1-7)\r\n");
822:io/mca25.c **** state = 4;
823:io/mca25.c **** }
824:io/mca25.c **** break;
825:io/mca25.c ****
826:io/mca25.c **** case 4:
827:io/mca25.c **** //wait for mux enable request
828:io/mca25.c **** if (string_compare_progmem_plen("AT+CMUX=0,0,7,31", mca25_buffer)){
829:io/mca25.c **** #if MCA25_DEBUG
830:io/mca25.c **** softuart_puts_progmem("at done, ");
831:io/mca25.c **** #endif
832:io/mca25.c **** mca25_send_ok();
833:io/mca25.c **** state = 10;
834:io/mca25.c **** }
835:io/mca25.c **** break;
836:io/mca25.c ****
837:io/mca25.c **** case 10:
838:io/mca25.c **** // wait for mux ch0 request:
839:io/mca25.c **** // [F9 03 3F 01 1C F9]
840:io/mca25.c **** //if (string_compare_progmem_plen("\xF9\x03\x3F\x01\x1C\xF9", mca25_buffer)){
841:io/mca25.c **** if ((mca25_mux_buffer[0] == 0x03) && (mca25_mux_buffer[2] == 0x01)){
842:io/mca25.c **** // send mux ch0 ack/open packet:
843:io/mca25.c **** // [F9 03 73 01 D7 F9]
844:io/mca25.c **** mca25_puts_progmem("\xF9\x03\x73\x01\xD7\xF9");
845:io/mca25.c **** state = 11;
846:io/mca25.c **** }
847:io/mca25.c **** break;
848:io/mca25.c ****
849:io/mca25.c **** case 11:
850:io/mca25.c **** // wait for mux ch3 request:
851:io/mca25.c **** // [F9 23 3F 01 C9 F9]
852:io/mca25.c **** //if (string_compare_progmem_plen("\xF9\x23\x3F\x01\xC9\xF9", mca25_buffer)){
853:io/mca25.c **** if ((mca25_mux_buffer[0] == 0x23) && (mca25_mux_buffer[2] == 0x01)){
854:io/mca25.c **** // send mux ch3 ack/open packet:
855:io/mca25.c **** // [F9 23 73 01 02 F9]
856:io/mca25.c **** mca25_puts_progmem("\xF9\x23\x73\x01\x02\xF9");
857:io/mca25.c **** state = 12;
858:io/mca25.c **** }
859:io/mca25.c **** break;
860:io/mca25.c ****
861:io/mca25.c **** case 12:
862:io/mca25.c **** // wait for config mux ch0 request:
863:io/mca25.c **** // [F9 03 EF 09 E3 05 23 8D FB F9]
864:io/mca25.c **** //if (string_compare_progmem_plen("\xF9\x03\xEF\x09\xE3\x05\x23\x8D\xFB\xF9", mca25_buffer)){
865:io/mca25.c **** if (string_compare_progmem_plen("\xE3\x05\x23\x8D", mca25_buffer)){
866:io/mca25.c **** // send mux ch0 config ack/open packet:
867:io/mca25.c **** // [F9 01 EF 0B E3 07 23 0C 01 79 F9]
868:io/mca25.c **** mca25_puts_progmem("\xF9\x01\xEF\x0B\xE3\x07\x23\x0C\x01\x79\xF9");
869:io/mca25.c **** state = 13;
870:io/mca25.c **** }
871:io/mca25.c **** break;
872:io/mca25.c ****
873:io/mca25.c **** case 13:
874:io/mca25.c **** // wait for config mux ch3 request:
875:io/mca25.c **** // [F9 03 EF 09 E1 07 23 0C 01 FB F9]
876:io/mca25.c **** //if (string_compare_progmem_plen("\xF9\x03\xEF\x09\xE1\x07\x23\x0C\x01\xFB\xF9", mca25_buffer
877:io/mca25.c **** if (string_compare_progmem_plen("\xE1\x07\x23\x0C\x01", mca25_buffer)){
878:io/mca25.c **** // send mux ch3 config ack/open packet:
879:io/mca25.c **** // [F9 01 EF 09 E1 05 23 8D 9A F9]
880:io/mca25.c **** mca25_puts_progmem("\xF9\x01\xEF\x09\xE1\x05\x23\x8D\x9A\xF9");
881:io/mca25.c **** state = 14;
882:io/mca25.c **** }
883:io/mca25.c **** break;
884:io/mca25.c ****
885:io/mca25.c **** case 14:
886:io/mca25.c **** // wait for AT*EACS.17.1.r:
887:io/mca25.c **** // [F9 23 EF 1B 41 54 2A 45 41 43 53 3D 31 37 2C 31 0D D1 F9]
888:io/mca25.c **** //if (memcmp(buf,"\xF9\x23\xEF\x1BAT*EACS=17,1\r\xD1\xF9",19) == 0){
889:io/mca25.c **** //if (string_compare_progmem_plen("\xF9\x23\xEF\x1B\x41\x54\x2A\x45\x41\x43\x53\x3D\x31\x37\x2
890:io/mca25.c **** if (string_compare_progmem_plen("\x41\x54\x2A\x45\x41\x43\x53\x3D\x31\x37\x2C\x31\x0D", mca25_
891:io/mca25.c **** // send mux "\r\nOK\r\n" packet:
892:io/mca25.c **** // [F9 21 EF 0D 0D 0A 4F 4B 0D 0A 48 F9]
893:io/mca25.c **** mca25_puts_progmem("\xF9\x21\xEF\x0D\x0D\x0A\x4F\x4B\x0D\x0A\x48\xF9");
894:io/mca25.c **** state = 15;
895:io/mca25.c **** }
896:io/mca25.c **** break;
897:io/mca25.c ****
898:io/mca25.c **** case 15:
899:io/mca25.c **** // wait for AT+CSCC=1,199\r5 peripheral AUTH req:
900:io/mca25.c **** // [F9 23 EF 1D 41 54 2B 43 53 43 43 3D 31 2C 31 39 39 0D 35 F9]
901:io/mca25.c **** //if (string_compare_progmem_plen("\xF9\x23\xEF\x1D\x41\x54\x2B\x43\x53\x43\x43\x3D\x31\x2C\x3
902:io/mca25.c **** if (string_compare_progmem_plen("\x41\x54\x2B\x43\x53\x43\x43\x3D\x31\x2C\x31\x39\x39\x0D", mc
903:io/mca25.c **** // send response token:
904:io/mca25.c **** //DONT// [F9 21 EF 1D 41 54 2B 43 53 43 43 3D 31 2C 31 39 39 0D 54 F9]
905:io/mca25.c **** // [F9 21 EF 1B 0D 0A 2B 43 53 43 43 3A 20 45 33 0D 0A B0 F9 ]
906:io/mca25.c **** //printf("\xF9\x21\xEF\x1D\x41\x54\x2B\x43\x53\x43"
907:io/mca25.c **** // "\x43\x3D\x31\x2C\x31\x39\x39\x0D\x54\xF9");
908:io/mca25.c **** mca25_puts_progmem("\xF9\x21\xEF\x1B\x0D\x0A\x2B\x43\x53\x43"
909:io/mca25.c **** "\x43\x3A\x20\x45\x33\x0D\x0A\xB0\xF9");
910:io/mca25.c ****
911:io/mca25.c **** //append ok:
912:io/mca25.c **** mca25_puts_progmem("\xF9\x21\xEF\x0D\x0D\x0A\x4F\x4B\x0D\x0A\x48\xF9");
913:io/mca25.c **** state = 16;
914:io/mca25.c **** }
915:io/mca25.c **** break;
916:io/mca25.c ****
917:io/mca25.c **** case 16:
918:io/mca25.c **** // wait for AT+CSCC=2,199.B9\r AUTH2 req:
919:io/mca25.c **** // AT+CSCC.2.199.B9.r|
920:io/mca25.c **** // [F9 23 EF 23 41 54 2B 43 53 43 43 3D 32 2C 31 39 39 2C 42 39 0D FB F9]
921:io/mca25.c **** //if (string_compare_progmem_plen("\xF9\x23\xEF\x23\x41\x54\x2B\x43\x53\x43\x43\x3D\x32\x2C\x3
922:io/mca25.c **** if (string_compare_progmem_plen("\x41\x54\x2B\x43\x53\x43\x43\x3D\x32\x2C\x31\x39\x39\x2C\x42\
923:io/mca25.c **** // send response token: (OK)
924:io/mca25.c **** // [F9 21 EF 0D 0D 0A 4F 4B 0D 0A 48 F9]
925:io/mca25.c **** mca25_puts_progmem("\xF9\x21\xEF\x0D\x0D\x0A\x4F\x4B\x0D\x0A\x48\xF9");
926:io/mca25.c ****
927:io/mca25.c **** // now request data mux channel (ch1):
928:io/mca25.c **** // [F9 81 3F 01 AB F9]
929:io/mca25.c **** mca25_puts_progmem("\xF9\x81\x3F\x01\xAB\xF9");
930:io/mca25.c **** state = 17;
931:io/mca25.c **** }
932:io/mca25.c **** break;
933:io/mca25.c ****
934:io/mca25.c **** case 17:
935:io/mca25.c **** // wait for mux ch1 ack:
936:io/mca25.c **** // [F9 81 73 01 60 F9]
937:io/mca25.c **** //if (string_compare_progmem_plen("\xF9\x81\x73\x01\x60\xF9", mca25_buffer)){
938:io/mca25.c **** if ((mca25_mux_buffer[0] == 0x81) && (mca25_mux_buffer[2] == 0x01)){
939:io/mca25.c **** // channel1 is now open!
940:io/mca25.c **** state = 18;
941:io/m
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -