{"action":"created","comment":{"url":"https://api.github.com/repos/mithro/fx2lib/pulls/comments/69509383","id":69509383,"diff_hunk":"@@ -0,0 +1,152 @@\n+/** \\file lib/uart/soft_uart.c\n+ * This file is for defining a common API for accessing UARTs.\n+ * Remarks By Roaring(for the FX2LP from cypress)\n+ **/\n+#include <fx2regs.h>\n+#include <fx2macros.h>\n+#include <uart/api.h>\n+#include <assert.h>\n+\n+/*This is set by calling the uartX_set_baud() function.*/\n+unsigned char load_delay;\n+BOOL uartX_init(enum uart_baud rate, ...)\n+{\n+    unsigned char clk_cmp;\n+    //Clear all bits except the CLKSPD[1:0]\n+    clk_cmp = CPUCS & 0x18;\n+    //If clock is currently set to 48Mhz,return TRUE\n+    if(clk_cmp == 0x10)\n+    \treturn TRUE;\n+    return FALSE;\n+}\n+\n+\n+void uart_tx(char c)\n+{\n+    //Done in ASM to improve performance. It takes only 6\n+    //cycles to move the data out, however a delay has been\n+    //introduced in order to get a baud rate of 115200\n+    //The mask which is to be written into the pin\n+    OEA |= 0x04;\n+    //An efficient UART bitbang routine in assembly\n+    __asm\n+    //Like #define in C. Can easily be used to change the pin\n+    //.equ _TX_PIN, _PA2\n+    //Disable interrupts\n+    //This is used because timing is critical\n+    //If the FX2 jumps into the ISR temporarily , it may cause transmit\n+    //errors. By clearing EA, we can disable interrupts\n+    clr _EA             //(2 cycles)\n+    //Move the data to be sent into the ACC\n+    //The data which is to be shifted out is held in the dpl register\n+    //We move the data into A for easy access to subsequent instructions\n+    mov a , dpl         //(2 cyles)\n+    clr c               //(1 cycle )\n+    //We need to send out 8 bits of data\n+    //Load r0 with value 8\n+    mov r0, #0x08       //(2 cycles)\n+    //Create the start bit\n+    clr _TX_PIN         //(2 cycles)\n+    //Precalculated delay since 1 cycle takes 88ns\n+    //At 12Mhz, it should be about 83.33ns\n+    //But it appears to be about 88ns\n+    //These numbers have been verified using an analyzer\n+    mov r1, _load_delay //(2 cycles)\n+    0006$:\n+    //1 bit is about 8.6us\n+    djnz r1, 0006$      //(3 cycles)\n+    //DJNZ on Rn takes 3 cycles\n+    //NOP takes about 1 cycle\n+    //Add 2 more cycles of delay\n+    //97 cycles\n+    nop                 //(1 cycle )\n+    nop                 //(1 cycle )\n+    0001$:","path":"lib/uart/soft_uart.c","position":null,"original_position":64,"commit_id":"82ae21829baf26985656fb57c67761c5ca48a721","original_commit_id":"50768056674a71ae7061bdf997f6a102d370ef24","user":{"login":"RacingTornado","id":9076332,"avatar_url":"https://avatars.githubusercontent.com/u/9076332?v=3","gravatar_id":"","url":"https://api.github.com/users/RacingTornado","html_url":"https://github.com/RacingTornado","followers_url":"https://api.github.com/users/RacingTornado/followers","following_url":"https://api.github.com/users/RacingTornado/following{/other_user}","gists_url":"https://api.github.com/users/RacingTornado/gists{/gist_id}","starred_url":"https://api.github.com/users/RacingTornado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RacingTornado/subscriptions","organizations_url":"https://api.github.com/users/RacingTornado/orgs","repos_url":"https://api.github.com/users/RacingTornado/repos","events_url":"https://api.github.com/users/RacingTornado/events{/privacy}","received_events_url":"https://api.github.com/users/RacingTornado/received_events","type":"User","site_admin":false},"body":"Please see the chapter on using labels in SDCC. I have rolled it back since it causes a multiple definition error , Pg 52 footnote 7","created_at":"2016-07-05T05:33:44Z","updated_at":"2016-07-05T05:33:44Z","html_url":"https://github.com/mithro/fx2lib/pull/18#discussion_r69509383","pull_request_url":"https://api.github.com/repos/mithro/fx2lib/pulls/18","_links":{"self":{"href":"https://api.github.com/repos/mithro/fx2lib/pulls/comments/69509383"},"html":{"href":"https://github.com/mithro/fx2lib/pull/18#discussion_r69509383"},"pull_request":{"href":"https://api.github.com/repos/mithro/fx2lib/pulls/18"}}},"pull_request":{"url":"https://api.github.com/repos/mithro/fx2lib/pulls/18","id":75077577,"html_url":"https://github.com/mithro/fx2lib/pull/18","diff_url":"https://github.com/mithro/fx2lib/pull/18.diff","patch_url":"https://github.com/mithro/fx2lib/pull/18.patch","issue_url":"https://api.github.com/repos/mithro/fx2lib/issues/18","number":18,"state":"open","locked":false,"title":"Implemented UART in accordance with the API definition in softuart.h to allow the example code to access printf() functionality","user":{"login":"RacingTornado","id":9076332,"avatar_url":"https://avatars.githubusercontent.com/u/9076332?v=3","gravatar_id":"","url":"https://api.github.com/users/RacingTornado","html_url":"https://github.com/RacingTornado","followers_url":"https://api.github.com/users/RacingTornado/followers","following_url":"https://api.github.com/users/RacingTornado/following{/other_user}","gists_url":"https://api.github.com/users/RacingTornado/gists{/gist_id}","starred_url":"https://api.github.com/users/RacingTornado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RacingTornado/subscriptions","organizations_url":"https://api.github.com/users/RacingTornado/orgs","repos_url":"https://api.github.com/users/RacingTornado/repos","events_url":"https://api.github.com/users/RacingTornado/events{/privacy}","received_events_url":"https://api.github.com/users/RacingTornado/received_events","type":"User","site_admin":false},"body":"- git clone https://github.com/RacingTornado/fx2lib\r\n- cd fx2lib\r\n- make\r\nFor fast_uart , git checkout branch_name\r\n- make\r\n- cd examples/uart_main\r\n- make\r\n- ./download.sh build/uart_main.ihx\r\n\r\nsudo minicom -H -w fastuart\r\n\r\nYou should have the parameters of fastuart set to 115200. You should see the values on the terminal.\r\n\r\nThe PA2 pin must be connected to the rx pin on the serial adaptor. In this situation , the ground must be the same also. Else you may get receiving errors. \r\n\r\nThe idea is to use this for debugging purposes. The baud rates is set to 115200 by setting the delay values. \r\n\r\nAnother important fact is that the console must be first opened up before loading the firmware onto the FX2. This is required for getting a lock on the start and the stop bits since there is no line break attached between the 2 bytes. \r\n\r\nCode has been cleaned up and the firmware in the examples directory is extremely small(less than 5-6 lines)\r\nAssembly has been extensively commented.\r\nI would like to merge this with the linux-descriptors branch since this is what I used as a base","created_at":"2016-06-24T08:00:29Z","updated_at":"2016-07-05T05:33:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bc1594f1aa4f958cb93515ce607486c320640ce3","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mithro/fx2lib/pulls/18/commits","review_comments_url":"https://api.github.com/repos/mithro/fx2lib/pulls/18/comments","review_comment_url":"https://api.github.com/repos/mithro/fx2lib/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mithro/fx2lib/issues/18/comments","statuses_url":"https://api.github.com/repos/mithro/fx2lib/statuses/82ae21829baf26985656fb57c67761c5ca48a721","head":{"label":"RacingTornado:fast_uart_try3","ref":"fast_uart_try3","sha":"82ae21829baf26985656fb57c67761c5ca48a721","user":{"login":"RacingTornado","id":9076332,"avatar_url":"https://avatars.githubusercontent.com/u/9076332?v=3","gravatar_id":"","url":"https://api.github.com/users/RacingTornado","html_url":"https://github.com/RacingTornado","followers_url":"https://api.github.com/users/RacingTornado/followers","following_url":"https://api.github.com/users/RacingTornado/following{/other_user}","gists_url":"https://api.github.com/users/RacingTornado/gists{/gist_id}","starred_url":"https://api.github.com/users/RacingTornado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RacingTornado/subscriptions","organizations_url":"https://api.github.com/users/RacingTornado/orgs","repos_url":"https://api.github.com/users/RacingTornado/repos","events_url":"https://api.github.com/users/RacingTornado/events{/privacy}","received_events_url":"https://api.github.com/users/RacingTornado/received_events","type":"User","site_admin":false},"repo":{"id":54301135,"name":"fx2lib","full_name":"RacingTornado/fx2lib","owner":{"login":"RacingTornado","id":9076332,"avatar_url":"https://avatars.githubusercontent.com/u/9076332?v=3","gravatar_id":"","url":"https://api.github.com/users/RacingTornado","html_url":"https://github.com/RacingTornado","followers_url":"https://api.github.com/users/RacingTornado/followers","following_url":"https://api.github.com/users/RacingTornado/following{/other_user}","gists_url":"https://api.github.com/users/RacingTornado/gists{/gist_id}","starred_url":"https://api.github.com/users/RacingTornado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RacingTornado/subscriptions","organizations_url":"https://api.github.com/users/RacingTornado/orgs","repos_url":"https://api.github.com/users/RacingTornado/repos","events_url":"https://api.github.com/users/RacingTornado/events{/privacy}","received_events_url":"https://api.github.com/users/RacingTornado/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/RacingTornado/fx2lib","description":"Library routines for creating firmware for the Cypress FX2 (CY7C68013 and variants) with SDCC","fork":true,"url":"https://api.github.com/repos/RacingTornado/fx2lib","forks_url":"https://api.github.com/repos/RacingTornado/fx2lib/forks","keys_url":"https://api.github.com/repos/RacingTornado/fx2lib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RacingTornado/fx2lib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RacingTornado/fx2lib/teams","hooks_url":"https://api.github.com/repos/RacingTornado/fx2lib/hooks","issue_events_url":"https://api.github.com/repos/RacingTornado/fx2lib/issues/events{/number}","events_url":"https://api.github.com/repos/RacingTornado/fx2lib/events","assignees_url":"https://api.github.com/repos/RacingTornado/fx2lib/assignees{/user}","branches_url":"https://api.github.com/repos/RacingTornado/fx2lib/branches{/branch}","tags_url":"https://api.github.com/repos/RacingTornado/fx2lib/tags","blobs_url":"https://api.github.com/repos/RacingTornado/fx2lib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RacingTornado/fx2lib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RacingTornado/fx2lib/git/refs{/sha}","trees_url":"https://api.github.com/repos/RacingTornado/fx2lib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RacingTornado/fx2lib/statuses/{sha}","languages_url":"https://api.github.com/repos/RacingTornado/fx2lib/languages","stargazers_url":"https://api.github.com/repos/RacingTornado/fx2lib/stargazers","contributors_url":"https://api.github.com/repos/RacingTornado/fx2lib/contributors","subscribers_url":"https://api.github.com/repos/RacingTornado/fx2lib/subscribers","subscription_url":"https://api.github.com/repos/RacingTornado/fx2lib/subscription","commits_url":"https://api.github.com/repos/RacingTornado/fx2lib/commits{/sha}","git_commits_url":"https://api.github.com/repos/RacingTornado/fx2lib/git/commits{/sha}","comments_url":"https://api.github.com/repos/RacingTornado/fx2lib/comments{/number}","issue_comment_url":"https://api.github.com/repos/RacingTornado/fx2lib/issues/comments{/number}","contents_url":"https://api.github.com/repos/RacingTornado/fx2lib/contents/{+path}","compare_url":"https://api.github.com/repos/RacingTornado/fx2lib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RacingTornado/fx2lib/merges","archive_url":"https://api.github.com/repos/RacingTornado/fx2lib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RacingTornado/fx2lib/downloads","issues_url":"https://api.github.com/repos/RacingTornado/fx2lib/issues{/number}","pulls_url":"https://api.github.com/repos/RacingTornado/fx2lib/pulls{/number}","milestones_url":"https://api.github.com/repos/RacingTornado/fx2lib/milestones{/number}","notifications_url":"https://api.github.com/repos/RacingTornado/fx2lib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RacingTornado/fx2lib/labels{/name}","releases_url":"https://api.github.com/repos/RacingTornado/fx2lib/releases{/id}","deployments_url":"https://api.github.com/repos/RacingTornado/fx2lib/deployments","created_at":"2016-03-20T04:55:00Z","updated_at":"2016-03-20T04:55:01Z","pushed_at":"2016-07-05T05:26:13Z","git_url":"git://github.com/RacingTornado/fx2lib.git","ssh_url":"git@github.com:RacingTornado/fx2lib.git","clone_url":"https://github.com/RacingTornado/fx2lib.git","svn_url":"https://github.com/RacingTornado/fx2lib","homepage":"http://fx2lib.sourceforge.net","size":1160,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mithro:linux-descriptors","ref":"linux-descriptors","sha":"0ddd377f85253c81cbd37afe2ab1a8da4e9969f4","user":{"login":"mithro","id":21212,"avatar_url":"https://avatars.githubusercontent.com/u/21212?v=3","gravatar_id":"","url":"https://api.github.com/users/mithro","html_url":"https://github.com/mithro","followers_url":"https://api.github.com/users/mithro/followers","following_url":"https://api.github.com/users/mithro/following{/other_user}","gists_url":"https://api.github.com/users/mithro/gists{/gist_id}","starred_url":"https://api.github.com/users/mithro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mithro/subscriptions","organizations_url":"https://api.github.com/users/mithro/orgs","repos_url":"https://api.github.com/users/mithro/repos","events_url":"https://api.github.com/users/mithro/events{/privacy}","received_events_url":"https://api.github.com/users/mithro/received_events","type":"User","site_admin":false},"repo":{"id":39321734,"name":"fx2lib","full_name":"mithro/fx2lib","owner":{"login":"mithro","id":21212,"avatar_url":"https://avatars.githubusercontent.com/u/21212?v=3","gravatar_id":"","url":"https://api.github.com/users/mithro","html_url":"https://github.com/mithro","followers_url":"https://api.github.com/users/mithro/followers","following_url":"https://api.github.com/users/mithro/following{/other_user}","gists_url":"https://api.github.com/users/mithro/gists{/gist_id}","starred_url":"https://api.github.com/users/mithro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mithro/subscriptions","organizations_url":"https://api.github.com/users/mithro/orgs","repos_url":"https://api.github.com/users/mithro/repos","events_url":"https://api.github.com/users/mithro/events{/privacy}","received_events_url":"https://api.github.com/users/mithro/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mithro/fx2lib","description":"Library routines for creating firmware for the Cypress FX2 (CY7C68013 and variants) with SDCC","fork":true,"url":"https://api.github.com/repos/mithro/fx2lib","forks_url":"https://api.github.com/repos/mithro/fx2lib/forks","keys_url":"https://api.github.com/repos/mithro/fx2lib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mithro/fx2lib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mithro/fx2lib/teams","hooks_url":"https://api.github.com/repos/mithro/fx2lib/hooks","issue_events_url":"https://api.github.com/repos/mithro/fx2lib/issues/events{/number}","events_url":"https://api.github.com/repos/mithro/fx2lib/events","assignees_url":"https://api.github.com/repos/mithro/fx2lib/assignees{/user}","branches_url":"https://api.github.com/repos/mithro/fx2lib/branches{/branch}","tags_url":"https://api.github.com/repos/mithro/fx2lib/tags","blobs_url":"https://api.github.com/repos/mithro/fx2lib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mithro/fx2lib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mithro/fx2lib/git/refs{/sha}","trees_url":"https://api.github.com/repos/mithro/fx2lib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mithro/fx2lib/statuses/{sha}","languages_url":"https://api.github.com/repos/mithro/fx2lib/languages","stargazers_url":"https://api.github.com/repos/mithro/fx2lib/stargazers","contributors_url":"https://api.github.com/repos/mithro/fx2lib/contributors","subscribers_url":"https://api.github.com/repos/mithro/fx2lib/subscribers","subscription_url":"https://api.github.com/repos/mithro/fx2lib/subscription","commits_url":"https://api.github.com/repos/mithro/fx2lib/commits{/sha}","git_commits_url":"https://api.github.com/repos/mithro/fx2lib/git/commits{/sha}","comments_url":"https://api.github.com/repos/mithro/fx2lib/comments{/number}","issue_comment_url":"https://api.github.com/repos/mithro/fx2lib/issues/comments{/number}","contents_url":"https://api.github.com/repos/mithro/fx2lib/contents/{+path}","compare_url":"https://api.github.com/repos/mithro/fx2lib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mithro/fx2lib/merges","archive_url":"https://api.github.com/repos/mithro/fx2lib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mithro/fx2lib/downloads","issues_url":"https://api.github.com/repos/mithro/fx2lib/issues{/number}","pulls_url":"https://api.github.com/repos/mithro/fx2lib/pulls{/number}","milestones_url":"https://api.github.com/repos/mithro/fx2lib/milestones{/number}","notifications_url":"https://api.github.com/repos/mithro/fx2lib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mithro/fx2lib/labels{/name}","releases_url":"https://api.github.com/repos/mithro/fx2lib/releases{/id}","deployments_url":"https://api.github.com/repos/mithro/fx2lib/deployments","created_at":"2015-07-19T03:57:20Z","updated_at":"2015-08-21T17:10:05Z","pushed_at":"2016-07-05T05:26:14Z","git_url":"git://github.com/mithro/fx2lib.git","ssh_url":"git@github.com:mithro/fx2lib.git","clone_url":"https://github.com/mithro/fx2lib.git","svn_url":"https://github.com/mithro/fx2lib","homepage":"http://fx2lib.sourceforge.net","size":870,"stargazers_count":1,"watchers_count":1,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":12,"forks":1,"open_issues":12,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mithro/fx2lib/pulls/18"},"html":{"href":"https://github.com/mithro/fx2lib/pull/18"},"issue":{"href":"https://api.github.com/repos/mithro/fx2lib/issues/18"},"comments":{"href":"https://api.github.com/repos/mithro/fx2lib/issues/18/comments"},"review_comments":{"href":"https://api.github.com/repos/mithro/fx2lib/pulls/18/comments"},"review_comment":{"href":"https://api.github.com/repos/mithro/fx2lib/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mithro/fx2lib/pulls/18/commits"},"statuses":{"href":"https://api.github.com/repos/mithro/fx2lib/statuses/82ae21829baf26985656fb57c67761c5ca48a721"}}}}
{"actor":{"display_login":"RacingTornado"}}