Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

printf test.

// Built with BFTC Rev. 1.0.0, mer 13 agosto 2014 11:56:10

/*
    Copyright 2014 Digital Technology Art SRL
    This file is part of Blackfin Toolchain (BFTC) project.

    BFTC is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    BFTC is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Nome-Programma.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "main.h"

int main(void)
{
    char        * ptr = "Hello world!";
    char        * np = 0;
    int         i = 5;
    unsigned int bs = sizeof(int) * 8;
    int         mi;
    char        buf[80];
    double      pi = 3.14159265358979323846264338327950288;
    
    Set_PLL(16, 4);     // CORE: 25MHz * 16 = 400MHz, SCLK: 400MHz / 4 = 100MHz
    Set_Uart0(115200);
    
    mi = (1 << (bs - 1)) + 1;
    
    while(1)
    {
        printf("\n\n");
        printf("Simple printf test\n");
        printf("Press any key to start ...\n");
        GetChar_Uart0();

        printf("%s\n", ptr);
        printf("termf test\n");
        printf("%s is null pointer\n", np);
        printf("%d = 5\n", i);
        printf("%d = - max int\n", mi);
        printf("char %c = 'a'\n", 'a');
        printf("hex %x = ff\n", 0xff);
        printf("hex %02x = 00\n", 0);
        printf("signed %d = unsigned %u = hex %X\n", -3, -3, -3);
        printf("%d %s(s)%%", 0, "message");
        printf("\n");
        printf("%d %s(s) with %%\n", 0, "message");
        sprintf(buf, "justif: \"%-10s\"\n", "left");
        printf("%s", buf);
        sprintf(buf, "justif: \"%10s\"\n", "right");
        printf("%s", buf);
        sprintf(buf, " 3: %04d zero padded\n", 3);
        printf("%s", buf);
        sprintf(buf, " 3: %-4d left justif.\n", 3);
        printf("%s", buf);
        sprintf(buf, " 3: %4d right justif.\n", 3);
        printf("%s", buf);
        sprintf(buf, "-3: %04d zero padded\n", -3);
        printf("%s", buf);
        sprintf(buf, "-3: %-4d left justif.\n", -3);
        printf("%s", buf);
        sprintf(buf, "-3: %4d right justif.\n", -3);
        printf("%s", buf);

        sprintf(buf, "%.2f is a double\n", 3.31);
        printf("%s", buf);

        sprintf(buf, "multiple unsigneds: %u %u %2u %X\n", 15, 5, 23, 0xB38F);
        printf("%s", buf);

        sprintf(buf, "multiple chars: %c %c %c %c\n", 'a', 'b', 'c', 'd');
        printf("%s", buf);

        sprintf(buf, "multiple doubles: %.2f %2.0f %.2f %.3f %.2f [%-8.3f]\n", 3.31, 2.45, -1.1, 3.093, 13.72, -4.382);
        printf("%s", buf);
        
        sprintf(buf, "PI = %.10f\n", pi);
        printf("%s", buf);
    }
    
    return 0;
}

Generated on Tue Apr 7 20:07:44 2015 for BF592A Library by doxygen 1.3.1