anchor.diff:  -behaviour(gen_server).
   
   %% API
  --export([start_link/0, stop/0, value/1]).
  --export([load_nif/0, init/0, pwm_value/1, pwm_release/0]).
  +-export([start_link/1, stop/1, value/2]).
  +-export([load_nif/0, pwm_init/0, pwm_value/1, pwm_release/0]).
   
   %% gen_server callbacks
   -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
  
positive.code: %% @doc Load the PWM C library.
  %% @end
  -spec(load_nif() -> ok | {error, error_type}).
  
  load_nif() ->
      ok = erlang:load_nif(?NIF_PWM_LIB, 0).
  
  %% @doc Initialise the PWM peripheral.
  %% @end
  -spec(init() -> ok | {error,pwm_initialization_error}).
  init() ->
      exit({error, pwm_initialization_error}).
  
  %% @doc Set PWM value.
  
negative.code: -define(SERVER, ?MODULE).
  -define(NIF_PWM_LIB, "../priv/pwm_nif").
  
  -type devname() :: string().
  -type channel() :: atom().
  
  %% @doc
  %% Start the process with the channel name and Initialize the devname device.
  %% You can identify the device by a channel name. Each channel drive a devname device.
  %% @end
  -spec(start_link({channel(), devname()}) -> {ok, pid()} | {error, reason}).
  start_link({Channel, Devname}) ->
      gen_server:start_link({local, Channel}, ?MODULE, Devname, []).
  
  %% @doc
  %% Stop the process channel and release it.
  %% @end
  stop(Channel) ->
      gen_server:cast(Channel, stop).
  
  %% @doc
  %% Assign a PWM value at the channel.
  %% @end
  value(Channel, X) -> 
      gen_server:call(Channel, {call, value, X}).
  
  %%%===================================================================
  %%% gen_server callbacks
  