serial_hardware

USART hardware control

Author Stef Mientki, Copyright (c) 2002..2006, all rights reserved.
Adapted-by Sebastien Lelong.
Compiler >=2.4g

Description

USART hardware control.
Routines for sending and receiving through the PIC-usart,
both asynchrone and synchrone are supported.
Baudrate can simply be set through a human constant,
because the baudrate depending registers are calculated by this unit.
Baudrate is calculated, starting at the high baudrate flag,
which will ensure the highest possible accuracy.


Dependencies


Summary

Global variables/contants

Procedures

Functions

Private

API details

Global variables/contants

Procedures

  • serial_hw_data'put(byte in data)

    Here Serial read and write are definied as pseudo variables
    so you use them as normal vars, like
     * wait for character being received,
     * then echo the inverted character
    {{{
    serial_hw_data = ! serial_hw_data
    }}}
    
    these procedures will wait till they can perform their action
    therefore it's better to use to following construct
    {{{
     if charater received, echo the inverted character
    if  serial_hw_data_available then
        serial_hw_data = ! serial_hw_data
    end if
     do other things
    }}}
    
    

  • serial_hw_init()

    Initializes the serial port, calculates baudrate registers.
    

  • serial_hw_write_word(word in data)

    like Serial_H_write, but then with a word as input
    The MSB is outputed first
    

  • serial_hw_write(byte in data)

    serial_hw_write - write char to serial port, blocking
    
    Asynchronuous serial send routine, using the TX pin
    Sends byte X (8 bit with no parity) to the serial port
    First checks (and waits if necessary) if transmit buffer is empty
    
    

  • serial_hw_data_raw'put(byte in data)

    These are real raw procedures, declared as pseudo variables
    the user is totally responsible for testing the transmit/receive
    flag before using these functions
    

  • serial_hw_enable()

    Enables USART
    

  • serial_hw_disable()

    Disables USART so ports can be used (temporary) for other purposes.
    USART can be enabled again by calling serial_hw_enable()
    

Functions

Private
  • _serial_hw_read(byte out data) return bit

    _serial_hw_read - internal use only!
    
    (using this inline function for serial_hw_data'get saves a stack level)
    Returns true if a character was received, otherwise returns false.
    Overrun error flag is cleared.
    
    



Related samples

Here are the list of samples which use this library:

16f648a16f648a_serial_hardware.jal
16f648a16f648a_serial_print.jal
16f648a16f648a_random.jal
16f648a16f648a_i2c_sw_l1.jal
16f648a16f648a_serial_format.jal
16f876a16f876a_t6603.jal
16f877a16f877a_random.jal
16f877a16f877a_i2c_sw_l1.jal
16f877a16f877a_co2_t6603.jal
16f877a16f877a_i2c_hw_slave_msg.jal
16f877a16f877a_serial_hardware.jal
16f877a16f877a_i2c_hw_l1.jal
16f877a16f877a_serial_format.jal
16f877a16f877a_print_serial_numbers.jal
16f877a16f877a_i2c_hw_slave_eeprom_simulator.jal
16f877a16f877a_i2c_sw_master_echo.jal
16f877a16f877a_serial_print.jal
16f8816f88_delay_basic.jal
16f8816f88_ir_ranger_gp2d02.jal
16f8816f88_serial_hw_echo.jal
16f8816f88_random.jal
16f8816f88_i2c_sw_l1.jal
16f8816f88_serial_hardware.jal
16f8816f88_remember_me.jal
16f8816f88_adc_lowres.jal
16f8816f88_i2c_sw_master_echo.jal
16f8816f88_print_serial_numbers.jal
16f8816f88_i2c_hw_slave_msg.jal
16f8816f88_i2c_hw_slave_eeprom_simulator.jal
16f8816f88_serial_print.jal
18f245018f2450_usb_hid_mouse.jal
18f245018f2450_serial_format.jal
18f245018f2450_usb_hid_keyboard.jal
18f245018f2450_i2c_sw_l1.jal
18f245018f2450_usb_hid_generic.jal
18f245018f2450_serial_hardware.jal
18f245018f2450_serial_print.jal
18f455018f4550_usb_hid_generic.jal
18f455018f4550_serial_format.jal
18f455018f4550_usb_hid_keyboard.jal
18f455018f4550_serial_hardware.jal
18f455018f4550_random.jal
18f455018f4550_serial_print.jal
18f455018f4550_i2c_sw_l1.jal
18f455018f4550_usb_hid_mouse.jal